From 8786ac439b00772235f107b2f98456e2dffc69de Mon Sep 17 00:00:00 2001 From: alyx Date: Sun, 24 Dec 2023 18:52:17 -0500 Subject: Docs basically done, need to revamp listentry interface probably --- src/bbss/site.py | 2 +- src/bbss/sizes.py | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) (limited to 'src/bbss') 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) -- cgit v1.2.3-70-g09d2