51 lines
3.6 KiB
JSON
51 lines
3.6 KiB
JSON
{
|
|
"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": "<bound method Alias.signature of Alias('Dict', 'typing.Dict')>",
|
|
"docstring": null
|
|
},
|
|
"List": {
|
|
"name": "List",
|
|
"kind": "alias",
|
|
"path": "mail_intake.parsers.headers.List",
|
|
"signature": "<bound method Alias.signature of Alias('List', 'typing.List')>",
|
|
"docstring": null
|
|
},
|
|
"Tuple": {
|
|
"name": "Tuple",
|
|
"kind": "alias",
|
|
"path": "mail_intake.parsers.headers.Tuple",
|
|
"signature": "<bound method Alias.signature of Alias('Tuple', 'typing.Tuple')>",
|
|
"docstring": null
|
|
},
|
|
"Optional": {
|
|
"name": "Optional",
|
|
"kind": "alias",
|
|
"path": "mail_intake.parsers.headers.Optional",
|
|
"signature": "<bound method Alias.signature of Alias('Optional', 'typing.Optional')>",
|
|
"docstring": null
|
|
},
|
|
"parse_headers": {
|
|
"name": "parse_headers",
|
|
"kind": "function",
|
|
"path": "mail_intake.parsers.headers.parse_headers",
|
|
"signature": "<bound method Function.signature of Function('parse_headers', 16, 64)>",
|
|
"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 <john@example.com>\"},\n {\"name\": \"Subject\", \"value\": \"Re: Interview Update\"},\n ]\n\n Output:\n {\n \"from\": \"John Doe <john@example.com>\",\n \"subject\": \"Re: Interview Update\",\n }\n ```"
|
|
},
|
|
"extract_sender": {
|
|
"name": "extract_sender",
|
|
"kind": "function",
|
|
"path": "mail_intake.parsers.headers.extract_sender",
|
|
"signature": "<bound method Function.signature of Function('extract_sender', 67, 102)>",
|
|
"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@example.com\", \"John Doe\")`\n - `\"john@example.com\"` -> `(\"john@example.com\", None)`"
|
|
}
|
|
}
|
|
}
|
|
} |