people.cli
Attributes
Functions
|
Deletes all people. |
|
Strips leading/trailing whitespace from first_name, last_name, |
|
Exports all people to an excel file. |
|
Imports people from an excel file. |
|
|
|
|
|
Read all rows from an .xls or .xlsx file as tuples of cell values. |
|
|
|
|
|
Find existing person by email or name and update, or create new. |
|
Imports people from a Horw municipality Excel export. |
|
Read the configured organisation_hierarchy as {top: {sub, ...}}. |
|
Imports people from an ogi-scraper |
|
Module Contents
- 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.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._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._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.jsonexport.The file is the JSON produced by ogi-scraper (e.g. the Malters
get_malters_people.pyscript): a list of person records withfirst_name,last_name,function,email,phone,location_address,location_code_cityandorganisations_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