Skip to main content

A simple Python utility for converting the weekly assignment PDF by the "Staatsanwaltschaft Freiburg"

Project description

sitzungsdienst

A simple Python utility for converting the weekly assignment PDF by the "Staatsanwaltschaft Freiburg" into csv, json as well as ics files.

Getting started

Running setup.bash will install all dependencies inside a virtual environment, ready for action:

# Set up & activate virtualenv
virtualenv -p python3 venv

# shellcheck disable=SC1091
source venv/bin/activate

# Install dependencies
python -m pip install --editable .

Usage

Using this library is straightforward:

$ sta --help
Usage: sta [OPTIONS] SOURCE

  Extract weekly assignments from SOURCE file.

Options:
  -o, --output PATH         Output filename, without extension.
  -d, --directory TEXT      Output directory.
  -f, --file-format TEXT    File format, "csv", "json" or "ics".
  -q, --query TEXT          Query assignees, eg for name, department.
  -i, --inquiries FILENAME  JSON file with parameters for automation.
  -c, --clear-cache         Remove existing files in directory first.
  -v, --verbose             Enable verbose mode.
  --version                 Show the version and exit.
  --help                    Show this message and exit.

The following code snippet provides a very basic batch processing example:

#!/bin/bash

# Create multiple calendar files at once
for arg; do
   sta -f ics -q "$arg" -o "$arg" source.pdf
done

Calling this script with something like bash script.bash alice bob charlie would give you alice.ics, bob.ics and charlie.ics, each containing their respective assignments.

However, you might want to store these information inside a json file and pass it via --inquiries:

[
    {
        "output": "study-group",
        "query": [
            "123",
            "456",
            "789"
        ]
    },
    {
        "output": "alice",
        "query": [
            "123"
        ]
    },
    {
        "output": "bob",
        "query": [
            "456"
        ]
    },
    {
        "output": "all-events",
        "query": []
    }
]

The output property resembles the filename whereas query contains all search terms. Therefore, the first entry is equivalent to this command: sta -o study-group -q 123 -q 456 -q 789 source.pdf.

Example

After installing this package, eg with pip install sitzungsdienst, the underlying module may also be used directly:

from sitzungsdienst import Sitzungsdienst

# Pass file path (or its stream)
sta = Sitzungsdienst(file_path)

# Retrieve data
data = sta.data

# Use a subset by filtering it
filtered = sta.filter(['alice', 'bob'])

If you want to see it in action, head over to the sitzungsapp!

Happy coding!

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

sitzungsdienst-1.6.0.tar.gz (21.6 kB view details)

Uploaded Source

Built Distribution

sitzungsdienst-1.6.0-py3-none-any.whl (21.8 kB view details)

Uploaded Python 3

File details

Details for the file sitzungsdienst-1.6.0.tar.gz.

File metadata

  • Download URL: sitzungsdienst-1.6.0.tar.gz
  • Upload date:
  • Size: 21.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.4.2 requests/2.25.1 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.9.5

File hashes

Hashes for sitzungsdienst-1.6.0.tar.gz
Algorithm Hash digest
SHA256 3f32ea8c2f37d66bb4a9408285ee80fd8fe8d443a8181e1b89f5cd4b4d0e8234
MD5 1f4a9396a6c09c91c174b9a004d50ab0
BLAKE2b-256 468a5146f340db496eb3bdf5dc9885a509aabe320e87c1dd4257d9c85e2e2438

See more details on using hashes here.

File details

Details for the file sitzungsdienst-1.6.0-py3-none-any.whl.

File metadata

  • Download URL: sitzungsdienst-1.6.0-py3-none-any.whl
  • Upload date:
  • Size: 21.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.4.2 requests/2.25.1 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.9.5

File hashes

Hashes for sitzungsdienst-1.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d56881045a18b55dff729c331e905566c97237243a00f8a89d2d0fb58ce9bf0e
MD5 1397e20f936502849d5b8e9d9d295e09
BLAKE2b-256 ebe7f3e566fe3f5bedc1e0af3efabfbabb12bb86d47632a6df53d126182de27f

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