Skip to content

Commit

Permalink
chore: logging
Browse files Browse the repository at this point in the history
  • Loading branch information
andylolz committed May 14, 2024
1 parent 98c2e38 commit 45113d0
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion x_notes/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,20 @@
from datetime import datetime, timezone
from typing import Any

from loguru import logger


def to_isoformat(ms_since_epoch: str) -> str:
return datetime.fromtimestamp(int(ms_since_epoch[:-3]), timezone.utc).isoformat()


def load_notes() -> dict[str, dict[str, Any]]:
fn = "output/data/notes.json"
try:
with open("output/data/notes.json") as fh:
with open(fn) as fh:
notes = {note["note_id"]: note for note in json.load(fh)}
except FileNotFoundError:
logger.warning(f"File not found: {fn}")
notes = {}
return notes

Expand Down

0 comments on commit 45113d0

Please sign in to comment.