aboutsummaryrefslogtreecommitdiffstats
path: root/src/bbss/lists.py
diff options
context:
space:
mode:
authoralyx <alyx@aleteoryx.me>2023-11-24 02:22:27 -0500
committeralyx <alyx@aleteoryx.me>2023-11-24 02:22:27 -0500
commit4d93c08e447f8d1d8d2a3206267856014adf4de7 (patch)
treeb973be6b895e60bef1f58cc1f85cc0f1511ed7bf /src/bbss/lists.py
parentca30a43450214fd9d4290bc95f0e340d82cf7b0d (diff)
downloadbbss.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/lists.py')
-rw-r--r--src/bbss/lists.py9
1 files changed, 5 insertions, 4 deletions
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