aboutsummaryrefslogtreecommitdiffstats
path: root/src/bbss
diff options
context:
space:
mode:
Diffstat (limited to 'src/bbss')
-rw-r--r--src/bbss/buttons.py3
-rw-r--r--src/bbss/lists.py9
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