diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/bbss/site.py | 2 | ||||
-rw-r--r-- | src/bbss/sizes.py | 7 |
2 files changed, 7 insertions, 2 deletions
diff --git a/src/bbss/site.py b/src/bbss/site.py index 134ee8b..3829ae9 100644 --- a/src/bbss/site.py +++ b/src/bbss/site.py @@ -6,7 +6,7 @@ from collections.abc import Sequence import requests class Site: - def __init__(self, domain: str, path: Optional[str], *, scheme: Optional[str]): + def __init__(self, domain: str, path: Optional[str] = None, *, scheme: Optional[str] = None): base = (scheme if scheme is not None else "https") + "://" + domain hit_sizefile = False 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) |