people.cli ========== .. py:module:: people.cli Attributes ---------- .. autoapisummary:: people.cli.cli people.cli.EXPORT_FIELDS people.cli._HORW_PERSONEN_HEADER people.cli._HORW_BEHOERDEN_HEADER people.cli._HORW_SUB_ORG_STRICT_MAP people.cli._HORW_SUB_ORG_ITEM_MAP Functions --------- .. autoapisummary:: people.cli.clear people.cli.strip_whitespace_from_names people.cli.export_xlsx people.cli.import_xlsx people.cli._v people.cli._join_address people.cli._read_excel_rows people.cli._parse_horw_personen_row people.cli._parse_horw_behoerden_row people.cli._upsert_horw_person people.cli.import_horw people.cli.list_people Module Contents --------------- .. py:data:: cli .. py:function:: clear(dry_run: bool) -> collections.abc.Callable[[onegov.core.request.CoreRequest, onegov.core.framework.Framework], None] Deletes all people. Does not support agencies and memberships at the moment. Example: onegov-people --select '/org/govikon' clear .. py:data:: EXPORT_FIELDS .. py:function:: strip_whitespace_from_names(dry_run: bool) -> collections.abc.Callable[[onegov.core.request.CoreRequest, onegov.core.framework.Framework], None] Strips leading/trailing whitespace from first_name, last_name, and function of all people. Example: `onegov-people --select /onegov_org/* strip-whitespace-from-names` `onegov-people --select /onegov_town6/* strip-whitespace-from-names` .. py:function:: export_xlsx(filename: str) -> collections.abc.Callable[[onegov.core.request.CoreRequest, onegov.core.framework.Framework], None] Exports all people to an excel file. Does not support agencies and memberships at the moment. Example: onegov-people --select '/onegov_org/govikon' export people.xlsx .. py:function:: import_xlsx(file: IO[bytes]) -> collections.abc.Callable[[onegov.core.request.CoreRequest, onegov.core.framework.Framework], None] Imports people from an excel file. Does not support agencies and memberships at the moment. Example: onegov-people --select '/onegov_org/govikon' import people.xlsx .. py:data:: _HORW_PERSONEN_HEADER :value: ('Name', 'Vorname', 'E-Mail', 'Internet', 'Funktion', 'Strasse', 'Nr.', 'PLZ', 'Ort', 'Telefon... .. py:data:: _HORW_BEHOERDEN_HEADER :value: ('Behörde', 'Strasse', 'Nr.', 'Postfach', 'PLZ', 'Ort', 'Telefon', 'E-Mail', 'URL / Homepage',... .. py:data:: _HORW_SUB_ORG_STRICT_MAP :type: dict[str, str] .. py:data:: _HORW_SUB_ORG_ITEM_MAP :type: dict[str, str] .. py:function:: _v(value: object) -> str | None .. py:function:: _join_address(*parts: object) -> str | None .. py:function:: _read_excel_rows(path: str) -> list[tuple[object, ...]] Read all rows from an .xls or .xlsx file as tuples of cell values. .. py:function:: _parse_horw_personen_row(v: tuple[object, ...]) -> dict[str, object] .. py:function:: _parse_horw_behoerden_row(v: tuple[object, ...]) -> dict[str, object] .. py:function:: _upsert_horw_person(people: onegov.people.collections.PersonCollection, first_name: str, last_name: str, extra: dict[str, object]) -> None Find existing person by email or name and update, or create new. .. py:function:: import_horw(file: str, dry_run: bool) -> collections.abc.Callable[[onegov.core.request.CoreRequest, onegov.core.framework.Framework], None] Imports people from a Horw municipality Excel export. Detects the file format automatically from the header row. Supports both the Personen export (one person per row) and the Behörden export (one membership per row, people deduplicated by email then name). Example: onegov-people --select /onegov_town6/horw import-horw export.xls .. py:function:: list_people() -> collections.abc.Callable[[onegov.core.request.CoreRequest, onegov.core.framework.Framework], None]