Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 12 additions & 18 deletions app_gui_full_updated.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# ==============================================================================
# ייבוא ספריות
# ==============================================================================
import customtkinter as ctk
from tkinter import ttk, filedialog, messagebox
import tkinter as tk
from tkcalendar import DateEntry
from datetime import date, timedelta, datetime
import math
import locale
import os
import sys
import webbrowser
from pyluach import dates, hebrewcal
import customtkinter as ctk
from tkinter import ttk, filedialog, messagebox
import tkinter as tk
from tkcalendar import DateEntry
from datetime import date, timedelta, datetime
import math
import locale
import os
import webbrowser
from pyluach import dates, hebrewcal
from hspek.utils.paths import resource_path

# ייבוא פונקציות לוגיות מהמודול הנפרד
from torah_logic_full_updated import (
Expand All @@ -35,13 +35,7 @@
ctk.set_appearance_mode("system") # הגדרת ערכת נושא בהתאם למערכת
ctk.set_default_color_theme("blue") # הגדרת צבע ברירת מחדל

DEFAULT_FILE = "torah_tree_data_full.json" # קובץ נתונים ברירת מחדל

def resource_path(filename):
"""החזרת נתיב לקובץ – עובד גם בפיתוח וגם בתוך EXE"""
if hasattr(sys, '_MEIPASS'):
return os.path.join(sys._MEIPASS, filename)
return os.path.join(os.path.abspath("."), filename)
DEFAULT_FILE = "torah_tree_data_full.json" # קובץ נתונים ברירת מחדל

# ==============================================================================
# מחלקת האפליקציה הראשית
Expand Down
1 change: 1 addition & 0 deletions hspek/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Hspek package root."""
1 change: 1 addition & 0 deletions hspek/utils/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Utility helpers for Hspek."""
8 changes: 8 additions & 0 deletions hspek/utils/paths.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import os
import sys

def resource_path(filename: str) -> str:
"""Return absolute path to a resource file, compatible with PyInstaller."""
if hasattr(sys, '_MEIPASS'):
return os.path.join(sys._MEIPASS, filename)
return os.path.join(os.path.abspath("."), filename)
64 changes: 35 additions & 29 deletions tests/test_pdf_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,41 +4,47 @@
import shutil
import os
import pytest
import sys

sys.path.append(str(Path(__file__).resolve().parents[1]))
from hspek.utils.paths import resource_path


def test_write_bookmark_pdf(tmp_path):
module = load_module()
tree = {"t": {"פרקים": 1}}
old_cwd = os.getcwd()
os.chdir(tmp_path)
repo_root = Path(__file__).resolve().parents[1]
map_src = repo_root / "sefaria_masechet_map.json"
if map_src.exists():
Path(tmp_path / "sefaria_masechet_map.json").write_bytes(map_src.read_bytes())
tree_src = repo_root / "torah_tree_data_full.json"
if tree_src.exists():
Path(tmp_path / "torah_tree_data_full.json").write_bytes(tree_src.read_bytes())
tpl_src = repo_root / "bookmark_template.html"
if tpl_src.exists():
Path(tmp_path / "bookmark_template.html").write_bytes(tpl_src.read_bytes())
# Skip if no Chromium/Chrome is available
if not (
os.environ.get("CHROME_PATH")
or shutil.which("chromium-browser")
or shutil.which("google-chrome")
or shutil.which("chromium")
or shutil.which("chrome")
):
pytest.skip("Chrome/Chromium not available")
map_src = Path(resource_path("sefaria_masechet_map.json"))
tree_src = Path(resource_path("torah_tree_data_full.json"))
tpl_src = Path(resource_path("bookmark_template.html"))
pdf_path = None
try:
os.chdir(tmp_path)
if map_src.exists():
Path(tmp_path / "sefaria_masechet_map.json").write_bytes(map_src.read_bytes())
if tree_src.exists():
Path(tmp_path / "torah_tree_data_full.json").write_bytes(tree_src.read_bytes())
if tpl_src.exists():
Path(tmp_path / "bookmark_template.html").write_bytes(tpl_src.read_bytes())
# Skip if no Chromium/Chrome is available
if not (
os.environ.get("CHROME_PATH")
or shutil.which("chromium-browser")
or shutil.which("google-chrome")
or shutil.which("chromium")
or shutil.which("chrome")
):
pytest.skip("Chrome/Chromium not available")

pdf_path = module.write_bookmark_pdf(
titles_list=["t"],
mode="פרקים",
start_date=date(2024, 1, 1),
end_date=date(2024, 1, 1),
tree_data=tree,
no_study_weekdays_set=set(),
)
os.chdir(old_cwd)
pdf_path = module.write_bookmark_pdf(
titles_list=["t"],
mode="פרקים",
start_date=date(2024, 1, 1),
end_date=date(2024, 1, 1),
tree_data=tree,
no_study_weekdays_set=set(),
)
finally:
os.chdir(old_cwd)
assert pdf_path is not None
assert Path(pdf_path).exists()
5 changes: 4 additions & 1 deletion tests/test_torah_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@
from pathlib import Path
import pytest

sys.path.append(str(Path(__file__).resolve().parents[1]))
from hspek.utils.paths import resource_path


def load_module():
path = Path(__file__).resolve().parents[1] / "torah_logic_full_updated.py"
path = Path(resource_path("torah_logic_full_updated.py"))

# Stub external GUI/ICS dependencies so the module can be imported
if "customtkinter" not in sys.modules:
Expand Down
30 changes: 12 additions & 18 deletions torah_logic_full_updated.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,18 @@
from datetime import date, timedelta, datetime, time
from ics import Calendar, Event, DisplayAlarm
import json
import os
import sys
import re
from urllib.parse import quote_plus, quote
from pyluach import dates, hebrewcal, parshios
from jinja2 import Environment, FileSystemLoader
from collections import defaultdict
from datetime import date, timedelta, datetime, time
from ics import Calendar, Event, DisplayAlarm
import json
import os
import re
from urllib.parse import quote_plus, quote

from pyluach import dates, hebrewcal, parshios
from jinja2 import Environment, FileSystemLoader
from collections import defaultdict
from hspek.utils.paths import resource_path

# כתובת ברירת מחדל לפתיחת חומר הלימוד היומי
# {ref} מוחלף בהפניה המדויקת בספריא (לדוגמה "בראשית.א-ב")
DEFAULT_LESSON_LINK = "https://www.sefaria.org.il/he/{ref}"

def resource_path(filename):
"""החזרת נתיב לקובץ – עובד גם בפיתוח וגם בתוך EXE"""
if hasattr(sys, '_MEIPASS'):
return os.path.join(sys._MEIPASS, filename)
return os.path.join(os.path.abspath("."), filename)
DEFAULT_LESSON_LINK = "https://www.sefaria.org.il/he/{ref}"


# זיהוי קטגוריית התוכן (תנ"ך, משנה או תלמוד) לפי הנתיב המלא של היחידה
Expand Down