No project description provided
Project description
py-gesetze
Linking german legal norms, dependency-free & GDPR-friendly. py-gesetze
automatically transforms legal references into a
tags - batteries included.
This project is a Python port of the PHP library php-gesetze
.
Installation
It's available from PyPi using pip
:
pip install gesetze
Getting started
Using this library is straightforward.
Commandline
Pretty much self-explanatory - otherwise, --help
is your friend:
$ gesetze --help
Usage: gesetze [OPTIONS] COMMAND [ARGS]...
Utilities for indexing & analyzing german legal norms
Options:
-v, --verbose Enable verbose mode.
--version Show the version and exit.
--help Show this message and exit.
Commands:
analyze Analyzes legal norm
build Builds index
clear Clears download cache
Package
The underlying module may also be used directly:
from gesetze import Gesetz, analyze
# Initialize it
obj = Gesetz()
# Configure it
obj.title = 'normal'
# Convert legal references
print(obj.gesetzify('This text references Art. 1 GG.'))
# "This text references <a class="hover:underline" href="https://www.gesetze-im-internet.de/gg/art_1.html" title="Grundgesetz für die Bundesrepublik Deutschland">Art. 1 GG</a>."
print(analyze('§ 433 Abs. 2 BGB'))
# {'norm': '433', 'absatz': '2', 'gesetz': 'BGB'}
Usage
__init(drivers: typing.Union[str, list])
drivers
controls the providers (and their respective order) to be used, either str
or list
.
Note: This defaults to all available drivers, which is a good overall choice, simply because of the vast array of supported laws. However, possible values are gesetze
, 'dejure'
, 'buzer'
and 'lexparency'
.
analyze(string: str) -> dict
Analyzes a single legal norm
extract(string: str) -> list
Extracts legal norms as list of strings
gesetzify(string: str, callback: typing.Callable) -> str
Transforms legal references into HTML link tags
Note: For more flexibility, you may use your own callback
method as second parameter of gesetzify
. Callbacks are being passed the re.Match
object representing matched legal norms. This way, you could highlight them using <strong>
tags instead of converting them into a
tags. Default: obj.linkify
Example: Inside the callback function, the match
for '§ 433 Abs. 2 BGB' (match.group(0)
) would give a dictionary like {'norm': '433', 'absatz': '2', 'satz': None, 'nr': None, 'lit': None, 'gesetz': 'BGB'}
(eg using match.groupdict()
).
Note: For convenience, a Markdown callback is included and may be used like this: obj.gesetzify('your-text', obj.markdownify)
roman2arabic(string: str)
Converts roman numerals to arabic numerals (static method)
Configuration
The gesetzify
command may be configured through the following options:
obj.attributes (dict)
Defines HTML attribute defaults. Default: {'target': '_blank'}
obj.title (False|str)
Controls title
attribute. Default: False
Possible values:
light
: abbreviated law (eg 'GG')normal
: complete law (eg 'Grundgesetz')full
: official heading (eg 'Art 45d Parlamentarisches Kontrollgremium')
Contributing
If you want to get your hands dirty, this will download the repository and install py-gesetze
along its dependencies inside a virtual environment, ready for action:
# Clone repository & change directory
git clone https://codeberg.org/S1SYPHOS/py-gesetze && cd py-gesetze
# Set up & activate virtualenv
virtualenv -p python3 venv && source venv/bin/activate
# Install dependencies
python -m pip install --editable .
Credits
This library is based on ..
- .. an adapted (and somewhat improved) version of the
jura_regex
regex package by Philipp Kiersch. - .. an adapted (and somewhat modified) version of the
gesetze
crawler package by Matej Grahovac.
Special Thanks
I'd like to thank everybody that's making free & open source software - you people are awesome. Also I'm always thankful for feedback and bug reports :)
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
Built Distribution
File details
Details for the file gesetze-1.1.0.tar.gz
.
File metadata
- Download URL: gesetze-1.1.0.tar.gz
- Upload date:
- Size: 2.6 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.0.1 pkginfo/1.4.2 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.9.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 377c30fe2ffeb928caecf7f5371904867d0c50a31b4dcb768a132460f9a5f919 |
|
MD5 | f9df1a8b19372bc87f504293ce94f484 |
|
BLAKE2b-256 | c7a33d1968a6de0412a435ec2fc8c2f05cdd35710ac653fd3e5be16f336c4dd8 |
File details
Details for the file gesetze-1.1.0-py3-none-any.whl
.
File metadata
- Download URL: gesetze-1.1.0-py3-none-any.whl
- Upload date:
- Size: 2.7 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.0.1 pkginfo/1.4.2 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.9.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0b7653bfb7f25f25bfed473a1eceb406f151c1f57dbeb8552cf1fe1f1ccbe594 |
|
MD5 | 951745119a364140f89a4e05c63e2cf8 |
|
BLAKE2b-256 | dda66a6450da937129e36d13e56a6c4b87496dc2d5267361b69078ffdf9e6594 |