pas.cli

Attributes

Processor

log

cli

Functions

import_commission_data(→ Processor)

Import commission data from an Excel or csv file.

check_api(→ None)

Check if the KuB API is reachable.

fetch_api_data_with_pagination(→ list[dict[str, Any]])

Fetches all data from a paginated API endpoint.

create_mock_file_data(→ onegov.core.types.LaxFileDict)

perform_kub_import(→ tuple[dict[str, Any], list[Any], ...)

Reusable function that performs KUB data import.

import_kub_data(→ Processor)

Import data from the KUB API endpoints.

update_custom_data(→ Processor)

Update parliamentarians with customFields data which

Module Contents

type pas.cli.Processor = Callable[[TownRequest, PasApp], None][source]
pas.cli.log[source]
pas.cli.cli[source]
pas.cli.import_commission_data(excel_file: str) Processor[source]

Import commission data from an Excel or csv file.

Assumes that the name of the commission is the filename.

Each row of this import contains a single line, which is a single parliamentarian and all the information about them.

Example:

onegov-pas –select ‘/onegov_pas/zug’ import-commission-data “Kommission_Gesundheit_und_Soziales.xlsx”

pas.cli.check_api(url: str, token: str) None[source]

Check if the KuB API is reachable.

Example:

onegov-pas check-api –token “your-token-here”

pas.cli.fetch_api_data_with_pagination(endpoint: str, token: str, base_url: str) list[dict[str, Any]][source]

Fetches all data from a paginated API endpoint.

Args:
endpoint: The API endpoint (e.g., ‘people’, ‘organizations’,

‘memberships’)

token: Authorization token base_url: Base URL for the API

Returns:

List of all records from all pages

pas.cli.create_mock_file_data(data: list[dict[str, Any]], filename: str) onegov.core.types.LaxFileDict[source]
pas.cli.perform_kub_import(request: onegov.pas.app.TownRequest, app: onegov.pas.app.PasApp, token: str, base_url: str, output: onegov.pas.log.OutputHandler | None = None) tuple[dict[str, Any], list[Any], list[Any], list[Any]][source]

Reusable function that performs KUB data import.

Args:

request: TownRequest object app: PasApp object token: Authorization token for KUB API base_url: Base URL for the KUB API output: Optional output handler for progress messages

Returns:
Tuple of (import_results, people_data, organization_data,

membership_data)

pas.cli.import_kub_data(token: str, base_url: str) Processor[source]

Import data from the KUB API endpoints.

Fetches data from /people, /organizations, and /memberships endpoints and imports them using the existing import logic.

Example:

onegov-pas –select ‘/onegov_pas/zug’ import-kub-data –token “your-token-here”

pas.cli.update_custom_data(token: str, base_url: str) Processor[source]

Update parliamentarians with customFields data which somehow is not included in the main /people api. Needs to be run after import_kub_data

Example:

onegov-pas –select ‘/onegov_pas/zug’ update-custom-data –token “your-token-here” –base-url “url-ending-in/api/v2”