aboutsummaryrefslogtreecommitdiffstats
path: root/src/bbss/buttons.py
diff options
context:
space:
mode:
authoralyx <alyx@aleteoryx.me>2023-11-24 02:15:43 -0500
committeralyx <alyx@aleteoryx.me>2023-11-24 02:15:43 -0500
commitca30a43450214fd9d4290bc95f0e340d82cf7b0d (patch)
tree9dcada98d9bc3afe9b5ee57f144076a53dff7cbb /src/bbss/buttons.py
parentfea4addaa6659aff6b324ee4db4b4223df22d591 (diff)
downloadbbss.py-ca30a43450214fd9d4290bc95f0e340d82cf7b0d.tar.gz
bbss.py-ca30a43450214fd9d4290bc95f0e340d82cf7b0d.tar.bz2
bbss.py-ca30a43450214fd9d4290bc95f0e340d82cf7b0d.zip
Lists, buttons
Diffstat (limited to 'src/bbss/buttons.py')
-rw-r--r--src/bbss/buttons.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/bbss/buttons.py b/src/bbss/buttons.py
new file mode 100644
index 0000000..63de4d1
--- /dev/null
+++ b/src/bbss/buttons.py
@@ -0,0 +1,28 @@
+from .lists import ListFile, ListFileEntry, ListFileIterator
+from dataclasses import dataclass
+import requests
+
+@dataclass(frozen=True)
+class ButtonListFileEntry(ListFileEntry):
+ root: str
+
+ def url(self) -> str:
+ return self.root + "/" + self.entry
+
+ def exists(self) -> bool:
+ return requests.head(self.url()).ok
+
+class ButtonListFileIterator(ListFileIterator):
+ def __next__(self) -> ButtonListFileEntry:
+ return super().__next__()
+
+@dataclass(frozen=True)
+class ButtonListFile(ListFile):
+ def __init__(self, contents: str, root: str):
+ super().__init__(contents)
+ self.root = root
+
+ @classmethod
+ def from_url(cls, url: str):
+ (root, _, _) = url.rpartition('/')
+ return cls(requests.get(url, stream = False).text, root)