Skip to content

Commit

Permalink
joplin: don't set empty metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
marph91 committed Sep 29, 2024
1 parent 4d00fef commit 927f380
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 27 deletions.
32 changes: 7 additions & 25 deletions src/formats/joplin.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from collections import defaultdict
import datetime as dt
import enum
import math
from pathlib import Path

import common
Expand Down Expand Up @@ -79,28 +80,6 @@ def parse_data(self, file_or_folder: Path):
type_ = ItemType(int(metadata_json["type_"]))
if type_ == ItemType.NOTE:
title, body = common.split_h1_title_from_body(markdown)
# # TODO: Not represented in frontmatter.
# common.try_transfer_dicts(
# metadata_json,
# data,
# [
# "is_conflict",
# "author",
# "source_url",
# "source",
# "application_data",
# "order",
# "encryption_cipher_text",
# "encryption_applied",
# "markup_language",
# "is_shared",
# "share_id",
# "conflict_original_id",
# "master_key_id",
# "user_data",
# "deleted_time",
# ],
# )
note_imf = imf.Note(
title.strip(),
body.strip(),
Expand All @@ -112,13 +91,16 @@ def parse_data(self, file_or_folder: Path):
# int(metadata_json.get("todo_completed", False))
# ),
# due=int(metadata_json.get("todo_due", 0)),
author=metadata_json.get("author"),
author=metadata_json.get("author") or None,
source_application=self.format,
original_id=metadata_json["id"],
)
# not set is exported as 0.0
for key in ("latitude", "longitude", "altitude"):
if (val := metadata_json.get(key)) is not None:
setattr(note_imf, key, float(val))
if (val := metadata_json.get(key)) is not None and not math.isclose(
val_float := float(val), 0.0
):
setattr(note_imf, key, val_float)
parent_id_note_map.append((metadata_json["parent_id"], note_imf))
elif type_ == ItemType.FOLDER:
parent_id_notebook_map.append(
Expand Down
1 change: 0 additions & 1 deletion src/importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import logging
import os.path
from pathlib import Path
import platform
import re
import shutil
import urllib.parse
Expand Down
2 changes: 1 addition & 1 deletion test/data
Submodule data updated 27 files
+ reference_data/frontmatter/all/My Notebook/2940b57b94864d37a3ea4d6462a58c26.png
+ reference_data/frontmatter/all/My Notebook/7a5cbebc3b524804adc77f8715094e59.png
+6 −13 reference_data/frontmatter/all/My Notebook/Another note.md
+1 −5 reference_data/frontmatter/all/My Notebook/Nested Notebook/note in other notebook with same name.md
+5 −16 reference_data/frontmatter/all/My Notebook/Sample note with completed reminder.md
+1 −5 reference_data/frontmatter/all/My Notebook/photo card (image only).md
+3 −7 reference_data/frontmatter/all/Second notebook/note in second notebook with open reminder.md
+ reference_data/frontmatter/joplin/My Notebook/2940b57b94864d37a3ea4d6462a58c26.png
+ reference_data/frontmatter/joplin/My Notebook/7a5cbebc3b524804adc77f8715094e59.png
+6 −13 reference_data/frontmatter/joplin/My Notebook/Another note.md
+1 −5 reference_data/frontmatter/joplin/My Notebook/Nested Notebook/note in other notebook with same name.md
+5 −16 reference_data/frontmatter/joplin/My Notebook/Sample note with completed reminder.md
+1 −5 reference_data/frontmatter/joplin/My Notebook/photo card (image only).md
+3 −7 reference_data/frontmatter/joplin/Second notebook/note in second notebook with open reminder.md
+ reference_data/frontmatter/obsidian/My Notebook/2940b57b94864d37a3ea4d6462a58c26.png
+ reference_data/frontmatter/obsidian/My Notebook/7a5cbebc3b524804adc77f8715094e59.png
+3 −8 reference_data/frontmatter/obsidian/My Notebook/Another note.md
+4 −11 reference_data/frontmatter/obsidian/My Notebook/Sample note with completed reminder.md
+1 −1 reference_data/frontmatter/obsidian/My Notebook/photo card (image only).md
+2 −2 reference_data/frontmatter/obsidian/Second notebook/note in second notebook with open reminder.md
+ reference_data/joplin/test_1/My Notebook/2940b57b94864d37a3ea4d6462a58c26.png
+ reference_data/joplin/test_1/My Notebook/7a5cbebc3b524804adc77f8715094e59.png
+3 −8 reference_data/joplin/test_1/My Notebook/Another note.md
+4 −11 reference_data/joplin/test_1/My Notebook/Sample note with completed reminder.md
+1 −1 reference_data/joplin/test_1/My Notebook/photo card (image only).md
+2 −2 reference_data/joplin/test_1/Second notebook/note in second notebook with open reminder.md
+ test_data/joplin/test_1/29_04_2024.jex

0 comments on commit 927f380

Please sign in to comment.