aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authoralyx <alyx@aleteoryx.me>2023-12-24 18:52:17 -0500
committeralyx <alyx@aleteoryx.me>2023-12-24 18:52:17 -0500
commit8786ac439b00772235f107b2f98456e2dffc69de (patch)
tree4c509ed54db4b0f9ad213621121eb714edbfd7b9 /src
parentdefde6070677e806c40d5891543848fcb2001ef5 (diff)
downloadbbss.py-8786ac439b00772235f107b2f98456e2dffc69de.tar.gz
bbss.py-8786ac439b00772235f107b2f98456e2dffc69de.tar.bz2
bbss.py-8786ac439b00772235f107b2f98456e2dffc69de.zip
Docs basically done, need to revamp listentry interface probablyHEADmaster
Diffstat (limited to 'src')
-rw-r--r--src/bbss/site.py2
-rw-r--r--src/bbss/sizes.py7
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)