{ "module": "mail_intake.parsers.headers", "content": { "path": "mail_intake.parsers.headers", "docstring": "# Summary\n\nMessage header parsing utilities for Mail Intake.\n\nThis module provides helper functions for normalizing and extracting\nuseful information from provider-native message headers.\n\nThe functions here are intentionally simple and tolerant of malformed\nor incomplete header data.", "objects": { "Dict": { "name": "Dict", "kind": "alias", "path": "mail_intake.parsers.headers.Dict", "signature": "", "docstring": null }, "List": { "name": "List", "kind": "alias", "path": "mail_intake.parsers.headers.List", "signature": "", "docstring": null }, "Tuple": { "name": "Tuple", "kind": "alias", "path": "mail_intake.parsers.headers.Tuple", "signature": "", "docstring": null }, "Optional": { "name": "Optional", "kind": "alias", "path": "mail_intake.parsers.headers.Optional", "signature": "", "docstring": null }, "parse_headers": { "name": "parse_headers", "kind": "function", "path": "mail_intake.parsers.headers.parse_headers", "signature": "", "docstring": "Convert a list of Gmail-style headers into a normalized dict.\n\nArgs:\n raw_headers (List[Dict[str, str]]):\n List of header dictionaries, each containing `name` and `value` keys.\n\nReturns:\n Dict[str, str]:\n Dictionary mapping lowercase header names to stripped values.\n\nNotes:\n **Guarantees:**\n\n - Provider payloads (such as Gmail) typically represent headers as a\n list of name/value mappings.\n - This function normalizes them into a case-insensitive dictionary\n keyed by lowercase header names.\n\nExample:\n Typical usage:\n\n ```python\n Input:\n [\n {\"name\": \"From\", \"value\": \"John Doe \"},\n {\"name\": \"Subject\", \"value\": \"Re: Interview Update\"},\n ]\n\n Output:\n {\n \"from\": \"John Doe \",\n \"subject\": \"Re: Interview Update\",\n }\n ```" }, "extract_sender": { "name": "extract_sender", "kind": "function", "path": "mail_intake.parsers.headers.extract_sender", "signature": "", "docstring": "Extract sender email and optional display name from headers.\n\nArgs:\n headers (Dict[str, str]):\n Normalized header dictionary as returned by `parse_headers()`.\n\nReturns:\n Tuple[str, Optional[str]]:\n A tuple `(email, name)` where `email` is the sender email address\n and `name` is the display name, or `None` if unavailable.\n\nNotes:\n **Responsibilities:**\n\n - This function parses the `From` header and attempts to extract\n sender email address and optional human-readable display name.\n\nExample:\n Typical values:\n\n - `\"John Doe \"` -> `(\"john@example.com\", \"John Doe\")`\n - `\"john@example.com\"` -> `(\"john@example.com\", None)`" } } } }