Transport-for-the-North / caf.core

Core classes and definitions for CAF family of tools
GNU General Public License v3.0
0 stars 1 forks source link

SegmentsSuper lookup dictionary #13

Open wsp-mbuckley opened 9 months ago

wsp-mbuckley commented 9 months ago

Create a new property in SegmentsSuper enum class which defines all the segments in a lookup dictionary e.g.

@property
def segment_lookup(self) -> dict[SegmentsSuper, Segment]:
    return {
        self.MODE: Segment(name=self.value, values={1: "Walk", 2: "Cycle", ... 6: "Rail / underground"}),
        self.SOC: Segment(name=self.value, values={1: "High Skilled", ... 4: "Skilled"}),
    }

Replace the match statement in the get_segment method with a dictionary lookup e.g. seg = self.segment_lookup[self]

Could be possible to define all the segments in a text file and have segments super load from there to reduce the clutter in the actual Python files?