"""Special-use inference from folder names (SPEC §6.3 fallback heuristics). Used only when the server does not advertise SPECIAL-USE. Includes Polish names (Wysłane, Kosz, ...) alongside English/German, per the spec's i18n intent. """ from __future__ import annotations _NAME_MAP: dict[str, str] = { # sent "sent": "sent", "sent items": "sent", "sent mail": "sent", "wysłane": "sent", "wyslane": "sent", "elementy wysłane": "sent", "gesendet": "sent", # drafts "drafts": "drafts", "draft": "drafts", "robocze": "drafts", "kopie robocze": "drafts", "entwürfe": "drafts", # trash "trash": "trash", "deleted": "trash", "deleted items": "trash", "kosz": "trash", "papierkorb": "trash", # junk "junk": "junk", "spam": "junk", "bulk mail": "junk", "wiadomości-śmieci": "junk", # archive "archive": "archive", "archiwum": "archive", "all mail": "archive", "archiv": "archive", } def infer_special_use(path: str) -> str | None: """Infer a special_use value from a mailbox path/name (case-insensitive).""" if path.upper() == "INBOX": return "inbox" leaf = path.replace("\\", "/").split("/")[-1].strip().lower() return _NAME_MAP.get(leaf) or _NAME_MAP.get(path.strip().lower())