def parse_vladmodels_spec(spec: str) -> VladModel: """ Parse a *VladModels* specification string and return a :class:`VladModel`.
area = parse_vladmodels_spec("vladmodels katya y117 47 154").area_mm2 print(area) # → 7238 vladmodels katya y117 47 154
pytest test_vladmodel_parser.py If you just need the area without the extra ceremony: def parse_vladmodels_spec(spec: str) ->
return VladModel( brand=brand, name=name, code=code, width_mm=width, height_mm=height, ) ) @property def area_mm2(self) ->
@property def area_mm2(self) -> int: """Surface area in square millimetres (width × height).""" return self.width_mm * self.height_mm
def test_basic_parsing(): raw = "vladmodels katya y117 47 154" model = parse_vladmodels_spec(raw) assert model == VladModel( brand="vladmodels", name="katya", code="y117", width_mm=47, height_mm=154, ) assert model.area_mm2 == 47 * 154