diff options
author | alyx <alyx@aleteoryx.me> | 2023-11-24 02:22:27 -0500 |
---|---|---|
committer | alyx <alyx@aleteoryx.me> | 2023-11-24 02:22:27 -0500 |
commit | 4d93c08e447f8d1d8d2a3206267856014adf4de7 (patch) | |
tree | b973be6b895e60bef1f58cc1f85cc0f1511ed7bf /src/bbss | |
parent | ca30a43450214fd9d4290bc95f0e340d82cf7b0d (diff) | |
download | bbss.py-4d93c08e447f8d1d8d2a3206267856014adf4de7.tar.gz bbss.py-4d93c08e447f8d1d8d2a3206267856014adf4de7.tar.bz2 bbss.py-4d93c08e447f8d1d8d2a3206267856014adf4de7.zip |
Wow, I forgot how to write python lmao
Diffstat (limited to 'src/bbss')
-rw-r--r-- | src/bbss/buttons.py | 3 | ||||
-rw-r--r-- | src/bbss/lists.py | 9 |
2 files changed, 7 insertions, 5 deletions
diff --git a/src/bbss/buttons.py b/src/bbss/buttons.py index 63de4d1..633dc0b 100644 --- a/src/bbss/buttons.py +++ b/src/bbss/buttons.py @@ -1,5 +1,6 @@ from .lists import ListFile, ListFileEntry, ListFileIterator from dataclasses import dataclass +from typing import cast import requests @dataclass(frozen=True) @@ -14,7 +15,7 @@ class ButtonListFileEntry(ListFileEntry): class ButtonListFileIterator(ListFileIterator): def __next__(self) -> ButtonListFileEntry: - return super().__next__() + return cast(ButtonListFileEntry, super().__next__()) @dataclass(frozen=True) class ButtonListFile(ListFile): diff --git a/src/bbss/lists.py b/src/bbss/lists.py index 3d4779e..234d0f8 100644 --- a/src/bbss/lists.py +++ b/src/bbss/lists.py @@ -1,11 +1,12 @@ from dataclasses import dataclass from collections.abc import Iterable, Iterator +from typing import Optional import requests @dataclass(frozen=True) class ListFileEntry: entry: str - comment: str + comment: Optional[str] class ListFileIterator(Iterator[ListFileEntry]): def __init__(self, entries: list[ListFileEntry]): @@ -23,13 +24,13 @@ class ListFile(Iterable[ListFileEntry]): self._contents = contents acc = [] comment_acc = "" - for line in str.splitlines(): + for line in contents.splitlines(): if line.startswith("#"): continue elif line.startswith("##"): - comment_acc += line[2:].split() + comment_acc += line[2:].strip() else: - acc += ListFileEntry(comment = comment_acc if comment_acc else None, entry = line) + acc.append(ListFileEntry(comment = comment_acc if comment_acc else None, entry = line)) self._entries = acc |