aboutsummaryrefslogtreecommitdiffstats
path: root/src/bbss/sizes.py
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/bbss/sizes.py
parentdefde6070677e806c40d5891543848fcb2001ef5 (diff)
downloadbbss.py-master.tar.gz
bbss.py-master.tar.bz2
bbss.py-master.zip
Docs basically done, need to revamp listentry interface probablyHEADmaster
Diffstat (limited to 'src/bbss/sizes.py')
-rw-r--r--src/bbss/sizes.py7
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)