Skip to content

Commit

Permalink
simplenotes: fix some lint warnings and add test data
Browse files Browse the repository at this point in the history
  • Loading branch information
marph91 committed Jan 5, 2025
1 parent 5e20b4a commit ad4e2b9
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 12 deletions.
14 changes: 3 additions & 11 deletions src/formats/standard_notes.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ def convert(self, file_or_folder: Path):
for item in input_json["items"]:
if item["content_type"] != "Note" or item.get("deleted", False):
continue
title = item["content"].get("title", common.unique_title())
title = item["content"].get("title", common.unique_title())
self.logger.debug(f'Converting note "{title}"')
note_imf = imf.Note(
title,
Expand All @@ -266,17 +266,9 @@ def convert(self, file_or_folder: Path):
case "plain-text":
note_imf.body = item["content"]["text"]
case "super":
body = item["content"]["text"]

if body:
if body := item["content"]["text"]:
super_converter = SuperToMarkdown()
try:
note_imf.body = super_converter.convert(item["content"]["text"])
except json.JSONDecodeError as e:
self.logger.warning(
f"Skipping Super Note '{title}' due to JSON parse error: {e}"
)
continue
note_imf.body = super_converter.convert(body)
else:
note_imf.body = ""

Expand Down
1 change: 1 addition & 0 deletions test/test_convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ def compare_dirs(dir1: Path, dir2: Path):
[["standard_notes/test_1/Standard Notes - Sun Apr 28 2024 12_56_55.zip"]],
[["standard_notes/test_2/Standard.Notes.-.super_format.GMT+0100.zip"]],
[["standard_notes/test_3/backup.zip"]],
[["standard_notes/test_4/SN-Empty-SuperNote-Backup.zip"]],
[["synology_note_station/test_1/20240331_144226_11102_Lagavulin.nsx"]],
[["synology_note_station/test_2/20240409_202124_7594_Lagavulin.nsx"]],
[["synology_note_station/test_3/notestation-test-books.nsx"]],
Expand Down

0 comments on commit ad4e2b9

Please sign in to comment.