# Path: app/util.py
# def cached_function(func: Callable[..., Any]) -> Callable[..., Any]:
#     data = {}
# 
#     def wrapper(*args: Any) -> Any:
#         if not SHOULD_CACHE:
#             return func(*args)
#         cache_key = ' '.join([str(x) for x in args])
#         if cache_key not in data:
#             data[cache_key] = func(*args)
#         return data[cache_key]
# 
#     wrapper.__qualname__ = func.__qualname__
#     wrapper.__signature__ = inspect.signature(func)  # type: ignore
#     return wrapper


import datetime
import os
import markdown2
from typing import Any, List, Optional, cast
from zoneinfo import ZoneInfo
from varsnap import varsnap
from app.util import cached_function
    @staticmethod
    def get_note_file_data(note_file: str) -> Optional["Note"]:
        with open(note_file) as note_handle:
            lines = note_handle.readlines()
        lines = [line.strip("\n") for line in lines]
        if len(lines) < 4 or not lines[4].isdigit():
            return None
        note_parsed = Note()
        note_parsed.note_file = note_file
        note_parsed.title = lines[0]
        note_parsed.slug = lines[2]
        note_parsed.time = Note.parse_time(lines[4])
        note_parsed.markdown = '\n'.join(lines[6:])
        note_parsed.note = Note.parse_markdown(note_parsed.markdown)
        return note_parsed

    @staticmethod
    @varsnap
    def parse_time(timestamp_str: str) -> datetime.datetime:
        timestamp = int(timestamp_str)
        time = datetime.datetime.fromtimestamp(timestamp, TIMEZONE)
        return time

    @staticmethod
    @varsnap
    def parse_markdown(markdown: str) -> str:
        note = markdown2.markdown(markdown, extras=MARKDOWN_EXTRAS)
        note_str = cast(str, note)
        return note_str


# Path: app/util.py
# def cached_function(func: Callable[..., Any]) -> Callable[..., Any]:
#     data = {}
# 
#     def wrapper(*args: Any) -> Any:
#         if not SHOULD_CACHE:
#             return func(*args)
#         cache_key = ' '.join([str(x) for x in args])
#         if cache_key not in data:
#             data[cache_key] = func(*args)
#         return data[cache_key]
# 
#     wrapper.__qualname__ = func.__qualname__
#     wrapper.__signature__ = inspect.signature(func)  # type: ignore
#     return wrapper


# Path: app/note_util.py
import datetime
import os
import markdown2
from typing import Any, List, Optional, cast
from zoneinfo import ZoneInfo
from varsnap import varsnap
from app.util import cached_function

    @staticmethod
    def get_note_file_data(note_file: str) -> Optional["Note"]:
        with open(note_file) as note_handle:
            lines = note_handle.readlines()
        lines = [line.strip("\n") for line in lines]
        if len(lines) < 4 or not lines[4].isdigit():
            return None
        note_parsed = Note()
        note_parsed.note_file = note_file
        note_parsed.title = lines[0]
        note_parsed.slug = lines[2]
        note_parsed.time = Note.parse_time(lines[4])
        note_parsed.markdown = '\n'.join(lines[6:])
        note_parsed.note = Note.parse_markdown(note_parsed.markdown)
        return note_parsed

    @staticmethod
    @varsnap
    def parse_time(timestamp_str: str) -> datetime.datetime:
        timestamp = int(timestamp_str)
        time = datetime.datetime.fromtimestamp(timestamp, TIMEZONE)
        return time

    @staticmethod
    @varsnap
    def parse_markdown(markdown: str) -> str:
        note = markdown2.markdown(markdown, extras=MARKDOWN_EXTRAS)
        note_str = cast(str, note)
        return note_str


    def write_note(self) -> None: