+class Color(Textfiled):
+ 'Color incl. solidness/transparency field.'
+
+ def __init__(
+ self,
+ id_: str,
+ solid: bool,
+ wavelength: str
+ ) -> None:
+ self.id_ = id_
+ self.solid = solid
+ self.wavelength = wavelength
+
+ @classmethod
+ def from_textfile(
+ cls,
+ path: str
+ ) -> dict[str, Self]:
+ collected = {}
+ for id_, desc in [cls.tokify(line, 2) for line in cls.lines_of(path)]:
+ assert len(desc) > 1
+ assert desc[0] in {CHAR_PLUS, CHAR_MINUS}
+ collected[id_] = cls(id_, desc[0] == CHAR_PLUS, desc[1:])
+ return collected
+
+ def __str__(
+ self
+ ) -> str:
+ return (f'{self.id_:>3} '
+ f'{CHAR_PLUS if self.solid else CHAR_MINUS}{self.wavelength}')
+
+