diff --git a/.gitignore b/.gitignore index aa89886..80c7543 100644 --- a/.gitignore +++ b/.gitignore @@ -5,7 +5,7 @@ *.json !lang/*.json !keywords/*.json -!skus/*.json +!classification/*.json !package*.json # Be explicit about the most sensitive files diff --git a/skus/google_ou_roles.json b/classification/google_ou_roles.json similarity index 100% rename from skus/google_ou_roles.json rename to classification/google_ou_roles.json diff --git a/skus/education.json b/classification/m365_skus.json similarity index 100% rename from skus/education.json rename to classification/m365_skus.json diff --git a/google_connector.py b/google_connector.py index 5451ac6..06625a4 100644 --- a/google_connector.py +++ b/google_connector.py @@ -31,6 +31,8 @@ import threading from pathlib import Path from typing import Iterator, Optional +logger = logging.getLogger(__name__) + # ── google-auth / google-api-python-client ──────────────────────────────────── try: from google.oauth2 import service_account @@ -93,15 +95,21 @@ _MAX_EXPORT_BYTES = 20 * 1024 * 1024 # 20 MB _OU_ROLES_PATH = Path(__file__).parent / "classification" / "google_ou_roles.json" def _load_ou_roles() -> tuple[list, list]: - """Load student/staff OU prefix lists from skus/google_ou_roles.json. + """Load student/staff OU prefix lists from classification/google_ou_roles.json. Returns (student_prefixes, staff_prefixes) — both lowercased.""" try: import json as _j data = _j.loads(_OU_ROLES_PATH.read_text(encoding="utf-8")) students = [p.lower() for p in data.get("student_ou_prefixes", [])] staff = [p.lower() for p in data.get("staff_ou_prefixes", [])] + logger.info("[ou-roles] Loaded %d student + %d staff OU prefixes from classification/google_ou_roles.json", + len(students), len(staff)) return students, staff - except Exception: + except FileNotFoundError: + logger.warning("[ou-roles] classification/google_ou_roles.json not found — using hardcoded fallback prefixes only") + return ["/elever", "/students"], ["/personale", "/staff", "/lærere", "/ansatte"] + except Exception as e: + logger.error("[ou-roles] Failed to load classification/google_ou_roles.json: %s — using hardcoded fallback prefixes only", e) return ["/elever", "/students"], ["/personale", "/staff", "/lærere", "/ansatte"] def classify_ou_role(org_unit_path: str) -> str: