people.cli

Attributes

cli

EXPORT_FIELDS

_HORW_PERSONEN_HEADER

_HORW_BEHOERDEN_HEADER

_HORW_SUB_ORG_STRICT_MAP

_HORW_SUB_ORG_ITEM_MAP

Functions

clear(dry_run) → collections.abc.Callable[[onegov.core.request.CoreRequest, onegov.core.framework.Framework], None]

Deletes all people.

strip_whitespace_from_names(dry_run) → collections.abc.Callable[[onegov.core.request.CoreRequest, onegov.core.framework.Framework], None]

Strips leading/trailing whitespace from first_name, last_name,

export_xlsx(filename) → collections.abc.Callable[[onegov.core.request.CoreRequest, onegov.core.framework.Framework], None]

Exports all people to an excel file.

import_xlsx(file) → collections.abc.Callable[[onegov.core.request.CoreRequest, onegov.core.framework.Framework], None]

Imports people from an excel file.

_v(value) → str | None

_join_address(*parts) → str | None

_read_excel_rows(path) → list[tuple[object, ...]]

Read all rows from an .xls or .xlsx file as tuples of cell values.

_parse_horw_personen_row(v) → dict[str, object]

_parse_horw_behoerden_row(v) → dict[str, object]

_upsert_horw_person(people, first_name, last_name, extra) → None

Find existing person by email or name and update, or create new.

import_horw(file, dry_run) → collections.abc.Callable[[onegov.core.request.CoreRequest, onegov.core.framework.Framework], None]

Imports people from a Horw municipality Excel export.

_build_valid_orgs(app) → dict[str, set[str]]

Read the configured organisation_hierarchy as {top: {sub, ...}}.

import_from_ogi_scraper(file, dry_run) → collections.abc.Callable[[onegov.core.request.CoreRequest, onegov.core.framework.Framework], None]

Imports people from an ogi-scraper people.json export.

list_people() → collections.abc.Callable[[onegov.core.request.CoreRequest, onegov.core.framework.Framework], None]

Module Contents

people.cli.cli[source]
people.cli.clear(dry_run: bool) → collections.abc.Callable[[onegov.core.request.CoreRequest, onegov.core.framework.Framework], None][source]

Deletes all people.

Does not support agencies and memberships at the moment.

Example:

onegov-people –select ‘/org/govikon’ clear

people.cli.EXPORT_FIELDS[source]
people.cli.strip_whitespace_from_names(dry_run: bool) → collections.abc.Callable[[onegov.core.request.CoreRequest, onegov.core.framework.Framework], None][source]

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

people.cli.export_xlsx(filename: str) → collections.abc.Callable[[onegov.core.request.CoreRequest, onegov.core.framework.Framework], None][source]

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

people.cli.import_xlsx(file: IO[bytes]) → collections.abc.Callable[[onegov.core.request.CoreRequest, onegov.core.framework.Framework], None][source]

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

people.cli._HORW_PERSONEN_HEADER = ('Name', 'Vorname', 'E-Mail', 'Internet', 'Funktion', 'Strasse', 'Nr.', 'PLZ', 'Ort', 'Telefon...[source]
people.cli._HORW_BEHOERDEN_HEADER = ('Behörde', 'Strasse', 'Nr.', 'Postfach', 'PLZ', 'Ort', 'Telefon', 'E-Mail', 'URL / Homepage',...[source]
people.cli._HORW_SUB_ORG_STRICT_MAP: dict[str, str][source]
people.cli._HORW_SUB_ORG_ITEM_MAP: dict[str, str][source]
people.cli._v(value: object) → str | None[source]
people.cli._join_address(*parts: object) → str | None[source]
people.cli._read_excel_rows(path: str) → list[tuple[object, ...]][source]

Read all rows from an .xls or .xlsx file as tuples of cell values.

people.cli._parse_horw_personen_row(v: tuple[object, ...]) → dict[str, object][source]
people.cli._parse_horw_behoerden_row(v: tuple[object, ...]) → dict[str, object][source]
people.cli._upsert_horw_person(people: onegov.people.collections.PersonCollection, first_name: str, last_name: str, extra: dict[str, object]) → None[source]

Find existing person by email or name and update, or create new.

people.cli.import_horw(file: str, dry_run: bool) → collections.abc.Callable[[onegov.core.request.CoreRequest, onegov.core.framework.Framework], None][source]

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

people.cli._build_valid_orgs(app: onegov.core.framework.Framework) → dict[str, set[str]][source]

Read the configured organisation_hierarchy as {top: {sub, …}}.

people.cli.import_from_ogi_scraper(file: str, dry_run: bool) → collections.abc.Callable[[onegov.core.request.CoreRequest, onegov.core.framework.Framework], None][source]

Imports people from an ogi-scraper people.json export.

The file is the JSON produced by ogi-scraper (e.g. the Malters get_malters_people.py script): a list of person records with first_name, last_name, function, email, phone, location_address, location_code_city and organisations_multiple – a flat list where each top-level organisation is followed by its --prefixed sub-organisations.

People are matched by email, then by name, and updated in place, so the import is idempotent and can be re-run without creating duplicates. Organisations are validated against the configured organisation_hierarchy.

Example:

onegov-people –select /onegov_town6/abc import-from-ogi-scraper people.json

people.cli.list_people() → collections.abc.Callable[[onegov.core.request.CoreRequest, onegov.core.framework.Framework], None][source]