Skip to main content

Client for Gever of the canton of Zurich

Project description

PyPI Version Tests + Linting Python Code style: black

goifer logo

goifer

goifer is the glue code needed to extract information from the Gever (Geschäftsverwaltungssystem) of the canton of Zurich. It is a client for python to make requests to the Gever API.

goifer is Swiss German for spit/saliva, a pun on «Gever» and the «spit» needed to get something out of it.

Table of Contents

Installation

goifer is available on PyPI, so to install it simply use:

$ pip install goifer

Usage

See the examples directory for more scripts.

search

search is used to query an index (i.e. entity) and get results.

>>> import goifer
>>> result = goifer.search("canton_zurich", index="Wahlkreise", query="seq > 0")
>>> print(result)
SearchResponse(count=18, next_start_record=11)
>>> print(result.count)
18
>>> print(result[0])
{'obj_guid': '99221ca914ae43ab99935379dd4be037', 'seq': '2242327', 'idx': 'Wahlkreise', 'name': 'XIII Pfäffikon', 'nil': False, 'inaktiv': False}

The return value of search is iterable, so you can easily loop over it. Or you can use indices to access elements, e.g. result[1] to get the second element, or result[-1] to get the last one.

Even slicing is supported, so you can do things like only iterate over the first 5 elements using

for records in records[:5]:
   print(record)

indexes

To get a better idea of the available indexes, you can get all configured indexes with indexes:

>>> goifer.indexes('canton_zurich')
['Behoerden', 'SitzungenDetail', 'Geschaeft', 'Mitglieder', 'Parteien', 'Wahlkreise', 'Direktion', 'Geschaeftsart', 'Gremiumtyp', 'KRVersand', 'Ablaufschritt']

file

Some indexes return a reference to a document (called edokument or edocument). goifer generates a download URL for those documents:

>>> meetings = goifer.search("canton_zurich", "SitzungenDetail", "seq>0")
>>> meetings[0]['dokument']['edokument']
{'id': '9db1203429e04a39a233e56eab42feea-332', 'filename': '63. KR-Protokoll vom 9.7.2012, Nachmittag.pdf', 'version': {'nr': '1', 'rendition': {'extension': 'pdf', 'ansicht': 'PDF'}}, 'download_url': 'https://parlzhcdws.cmicloud.ch/parlzh3/cdws/Files/9db1203429e04a39a233e56eab42feea-332/1/PDF'}

The download_url can be used to download the file, the corresponding filename is in the filename field.

Sometimes you want to generate the download URL yourself, in these cases you can use the file method:

>>> import goifer
>>> client = goifer.client("canton_zurich")
>>> res = client.search("Mitglieder", "Name adj Marti and Vorname adj Res")[0]
>>> client.file("Mitglieder", res["foto_id"], res['foto_version']['nr'], 'Original')
'https://parlzhcdws.cmicloud.ch/parlzh2/cdws/Files/6bf54e3bdd24400d85e13169c3a5bbf8-1664/1/Original'

schema

To know what fields are in a search result or to check with fields are available for queries (i.e. searchfields), use the schema method:

>>> s = goifer.schema('canton_zurich', 'Wahlkreise')
{'targetnamespace': 'http://www.cmiag.ch/cdws/Wahlkreise', 'elementformdefault': 'qualified', 'annotation': {'documentation': {'searchfield': [{'type': 'SearchFieldBoolean', 'Name': 'inaktiv', 'BoostFactor': '1', 'Nrs': '6'}, {'type': 'SearchFieldText', 'Name': 'Name', 'BoostFactor': '1', 'Nrs': '5'}]}}, 'complextype': {'name': 'Wahlkreis', 'sequence': {'element': [{'name': 'Name', 'type': 'xsd:string'}, {'name': 'inaktiv', 'type': 'xsd:boolean', 'nillable': 'true'}]}, 'attribute': [{'name': 'OBJ_GUID', 'type': 'xsd:string', 'use': 'required'}, {'name': 'SEQ', 'type': 'xsd:string', 'use': 'optional'}, {'name': 'IDX', 'type': 'xsd:string', 'use': 'optional'}]}, 'element': {'name': 'Wahlkreis', 'type': 'Wahlkreis'}}

Development

To develop on this project, install flit:

pip install flit
flit install -s

Or use the provided dev_setup.sh script.

To contribute to goifer simply clone this repository and follow the instructions in CONTRIBUTING.md.

This project has a Makefile with the most common commands. Type make help to get an overview.

Release

To create a new release, follow these steps (please respect Semantic Versioning):

  1. Adapt the version number in goifer/__init__.py
  2. Update the CHANGELOG with the version
  3. Create a pull request to merge develop into main (make sure the tests pass!)
  4. Create a new release/tag on GitHub (on the main branch)
  5. The publication on PyPI happens via GitHub Actions on every tagged commit

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

goifer-0.0.5.tar.gz (28.4 kB view details)

Uploaded Source

Built Distribution

goifer-0.0.5-py3-none-any.whl (9.9 kB view details)

Uploaded Python 3

File details

Details for the file goifer-0.0.5.tar.gz.

File metadata

  • Download URL: goifer-0.0.5.tar.gz
  • Upload date:
  • Size: 28.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.28.1

File hashes

Hashes for goifer-0.0.5.tar.gz
Algorithm Hash digest
SHA256 4cc7dd340d8b91904375d0a5dc2d549d2b8e787ef740dc83d8ad9273c5c6979a
MD5 b6278663e355dbea52498fc26af45d4b
BLAKE2b-256 1183bf2b9742c7b77266d6151abf1ccbaf724635fb11ba06f9460015548ee01e

See more details on using hashes here.

File details

Details for the file goifer-0.0.5-py3-none-any.whl.

File metadata

  • Download URL: goifer-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 9.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.28.1

File hashes

Hashes for goifer-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 9eac67f87513942042cbf2b78c39e9d6e8d261697ebfde340000afec3e059d62
MD5 5e1e0e04b6c1e769617e4f1d231dc866
BLAKE2b-256 7e2a69cc1bfb4398cebfd4c506f37dec45b344ac9dea7507c0b303edbd164b36

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page