fix: Do not parse the last ReadEra section

This commit is contained in:
Marty Oehme 2025-09-11 18:38:59 +02:00
parent db47ad686d
commit a9ff4152af
Signed by: Marty
GPG key ID: 4E535BC19C61886E
3 changed files with 35 additions and 19 deletions

View file

@ -44,11 +44,10 @@ class ReadEraExtractor:
def run(self, filename: Path) -> list[Annotation]:
"""Extract annotations from readera txt file.
Returns all readable annotations contained in the file
passed in, with highlights and notes if available.
Could theoretically return the annotation color but I
do not have access to a premium version of ReadEra so
I cannot add this feature.
Returns all readable annotations contained in the file passed in, with
highlights and notes if available. Could theoretically return the
annotation color but I do not have access to a premium version of
ReadEra so I cannot add this feature.
"""
content = self._read_file(filename)[2:]
if not content:
@ -56,7 +55,9 @@ class ReadEraExtractor:
annotations: list[Annotation] = []
split = "\n".join(content).split("\n*****\n")
# split for *** separators and remove the last entry since it is always
# empty
split = "\n".join(content).split("\n*****\n")[:-1]
note_pattern = re.compile(r"\n--.*")
for entry in split:
entry = entry.strip()