Skip to content

Commit 58d18bc

Browse files
committed
rednotebook: catch exceptions "monthly"
1 parent 37bf98b commit 58d18bc

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

jimmy/formats/rednotebook.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,15 @@ def handle_markdown_links(self, body: str) -> tuple[str, imf.Resources]:
4444
resources.append(imf.Resource(Path(link.url), original_link_text, link.text))
4545
return body, resources
4646

47+
@common.catch_all_exceptions
48+
def convert_month(self, file_: Path):
49+
year, month = file_.stem.split("-", 1)
50+
# data is encapsulated in yaml, notes are in txt2tags markup
51+
# see: https://rednotebook.app/help.html#toc38
52+
note_dict = yaml.safe_load(file_.read_text(encoding="utf-8"))
53+
for day, data in note_dict.items():
54+
self.convert_note(data, datetime.date(int(year), int(month), int(day)))
55+
4756
@common.catch_all_exceptions
4857
def convert_note(self, data: dict, date: datetime.date):
4958
title = date.strftime("%Y-%m-%d")
@@ -78,9 +87,4 @@ def convert(self, file_or_folder: Path):
7887
return
7988

8089
for file_ in sorted(notes):
81-
year, month = file_.stem.split("-", 1)
82-
# data is encapsulated in yaml, notes are in txt2tags markup
83-
# see: https://rednotebook.app/help.html#toc38
84-
note_dict = yaml.safe_load(file_.read_text(encoding="utf-8"))
85-
for day, data in note_dict.items():
86-
self.convert_note(data, datetime.date(int(year), int(month), int(day)))
90+
self.convert_month(file_)

0 commit comments

Comments
 (0)