diff options
Diffstat (limited to 'src/bbss/sizes.py')
-rw-r--r-- | src/bbss/sizes.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/bbss/sizes.py b/src/bbss/sizes.py index f71a94c..c1d58f5 100644 --- a/src/bbss/sizes.py +++ b/src/bbss/sizes.py @@ -1,9 +1,10 @@ from bbss.lists import BaseListFile, ListFileEntry, parse_listfile from bbss.buttons import ButtonListFile from dataclasses import dataclass -from typing import Optional, Self +from typing import Optional, Self, Tuple from collections.abc import Sequence import requests +import re @dataclass(frozen=True) class SizeListFileEntry(ListFileEntry): @@ -18,6 +19,10 @@ class SizeListFileEntry(ListFileEntry): def get(self) -> Optional[ButtonListFile]: return ButtonListFile.from_url(self.url()) + def dims(self) -> Optional[Tuple[int, int]]: + matches = re.match("^([0-9]+)x([0-9]+)$", self.entry) + return (matches[1], matches[2]) if matches is not None else None + class SizeListFile(BaseListFile[SizeListFileEntry]): def __init__(self, contents: str, root: str): super().__init__(contents) |