def from_textfile(
cls,
path: tuple[str, str],
- **kwargs
+ db: 'BricksDb'
) -> dict[str, Self]:
'Build from file at path.'
return self.raw()
-class _WithDb:
- 'Add db:Optional[BricksDB] field to __init__, setting .db.'
+class _Lookupable:
+ 'Adds .db, provides methods for BricksDb.lookup and .id_ padding.'
+ _id_indent: int = 0
+ id_: str
def __init__(
self,
self.db = db
super().__init__(**kwargs)
-
-class _Lookupable:
- 'Provides methods for BricksDb.lookup and .id_ padding.'
- _id_indent: int = 0
- id_: str
-
@classmethod
def indent_id(
cls,
}
-class _BrickColor(_Textfiled, _Lookupable, _WithDb):
+class _BrickColor(_Textfiled, _Lookupable):
'Color incl. solidness/transparency field.'
_id_indent = 3
def from_textfile(
cls,
path: tuple[str, str],
- db: Optional['BricksDb'] = None,
- **_
+ db: 'BricksDb'
) -> dict[str, Self]:
collected = {}
for id_, desc in [cls.tokify(line, 2) for line in cls.lines_of(path)]:
return attrs
-class _BrickDesign(_Textfiled, _WithDb, _Lookupable):
+class _BrickDesign(_Textfiled, _Lookupable):
'Shape and texture configurations with descriptions and equalities.'
_id_indent = 6
alternate_to: Optional[Self] = None
def from_textfile(
cls,
path: tuple[str, str],
- db: Optional['BricksDb'] = None,
- **_
+ db: 'BricksDb',
) -> dict[str, Self]:
collected = {}
alts: dict[str, set[str]] = {}
return f'{raw}{_CHAR_SEP_TOKEN.join(attrs)}'
-class _Brick(_Textfiled, _WithDb, _Lookupable):
+class _Brick(_Textfiled, _Lookupable):
'Individual configuration of design and color.'
_id_indent = 7
def from_textfile(
cls,
path: tuple[str, str],
- db: Optional['BricksDb'] = None,
- **_
+ db: 'BricksDb'
) -> dict[str, Self]:
collected = {}
for toks in [cls.tokify(line, 3) for line in cls.lines_of(path)]:
f'{design.description} ({color}){comment}')
-class _BrickSet(_Textfiled, _WithDb, _Lookupable):
+class _BrickSet(_Textfiled, _Lookupable):
'Named collection of bricks in order of pages of columns of counts.'
def __init__(
def from_textfile(
cls,
path: tuple[str, str],
- db: Optional['BricksDb'] = None,
- **_
+ db: 'BricksDb'
) -> dict[str, Self]:
collected: dict[str, tuple[Optional[bool],
str,
}
-class _Box(_WithDb, _Lookupable):
+class _Box(_Lookupable):
'Order of designs.'
_id_indent = 5
self._name_set_colors = name_set_colors
for name, cls in [(name, cls) for name, cls in self.lookupables.items()
if issubclass(cls, _Textfiled)]:
- kwargs = {'db': self} if issubclass(cls, _WithDb) else {}
setattr(self, name, cls.from_textfile((path_tables, f'{name}.txt'),
- **kwargs))
+ db=self))
self.ldraw = LdrawDb(Path(path_ldraw))
self._ldraw_modes = ldraw_modes.split(CHAR_SEP_LDRAW_MODES)
if _LDRAW_MODE_FILL_PATHS in self._ldraw_modes: