From 7df16e92a44e04e3997039f893f09c57a4ba30d2 Mon Sep 17 00:00:00 2001 From: Dmitry <124861781+ada-dmitry@users.noreply.github.com> Date: Fri, 12 Dec 2025 11:28:42 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B0=20=D0=B2=D1=81=D0=BF=D0=BE=D0=BC=D0=BE=D0=B3=D0=B0?= =?UTF-8?q?=D1=82=D0=B5=D0=BB=D1=8C=D0=BD=D0=B0=D1=8F=20=D1=84=D1=83=D0=BD?= =?UTF-8?q?=D0=BA=D1=86=D0=B8=D1=8F=20=5Fchildren=20=D0=B4=D0=BB=D1=8F=20?= =?UTF-8?q?=D1=83=D0=BF=D1=80=D0=BE=D1=89=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=BE?= =?UTF-8?q?=D0=B1=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=BA=D0=B8=20=D0=B4=D0=BE?= =?UTF-8?q?=D1=87=D0=B5=D1=80=D0=BD=D0=B8=D1=85=20=D1=8D=D0=BB=D0=B5=D0=BC?= =?UTF-8?q?=D0=B5=D0=BD=D1=82=D0=BE=D0=B2=20=D0=B8=20=D1=83=D0=BB=D1=83?= =?UTF-8?q?=D1=87=D1=88=D0=B5=D0=BD=D0=B0=20=D0=BB=D0=BE=D0=B3=D0=B8=D0=BA?= =?UTF-8?q?=D0=B0=20=D0=BF=D0=BE=D0=B8=D1=81=D0=BA=D0=B0=20=D0=BF=D0=B0?= =?UTF-8?q?=D0=BF=D0=BE=D0=BA=20=D0=B8=20=D0=B7=D0=B0=D0=BC=D0=B5=D1=82?= =?UTF-8?q?=D0=BE=D0=BA=20=D0=B2=20=D1=84=D1=83=D0=BD=D0=BA=D1=86=D0=B8?= =?UTF-8?q?=D0=B8=20save=5Fdaily?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/main.py b/main.py index 29b450e..d473e32 100644 --- a/main.py +++ b/main.py @@ -45,6 +45,12 @@ def _get_content(obj): return obj.get("content") if isinstance(obj, dict) else getattr(obj, "content", "") +def _children(obj): + if isinstance(obj, dict): + return obj.get("children") or [] + return getattr(obj, "children", []) or [] + + def _translate_month_en_ru(name: str) -> str: mapping = { "January": "Январь", @@ -101,11 +107,10 @@ def save_daily(text: str) -> str: # Ищем/создаём месяц month_folder = None - if hasattr(daily_root, "children"): - for child in daily_root.children: - if _get_title(child) == month_name: - month_folder = child - break + for child in _children(daily_root): + if _get_title(child) == month_name: + month_folder = child + break if not month_folder: month_folder = ea.create_note( @@ -117,11 +122,10 @@ def save_daily(text: str) -> str: # Ищем/создаём день day_folder = None - if hasattr(month_folder, "children"): - for child in month_folder.children: - if _get_title(child) == day_name: - day_folder = child - break + for child in _children(month_folder): + if _get_title(child) == day_name: + day_folder = child + break if not day_folder: day_folder = ea.create_note(parentNoteId=month_id, title=day_name, type="text") @@ -131,11 +135,10 @@ def save_daily(text: str) -> str: # Ищем заметку по дате existing_note = None - if hasattr(day_folder, "children"): - for child in day_folder.children: - if _get_title(child) == today_date: - existing_note = child - break + for child in _children(day_folder): + if _get_title(child) == today_date: + existing_note = child + break if existing_note: existing_content = _get_content(existing_note)