Package: gesetze
py-gesetzeLinking german legal norms, dependency-free & GDPR-friendly.py-gesetzeautomatically transforms legal references intoatags - batteries included.This project is a Python port of the PHP libraryphp-gesetze.InstallationIt's available fromPyPiusingpip:pip install gesetzeGetting startedUsing this library is straightforward.CommandlinePretty much self-explanatory - otherwise,--helpis 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
  clear    Clears download cache
  scrape   Scrapes legal norms from PROVIDERPackageThe underlying module may also be used directly:fromgesetzeimportGesetz,analyze# Initialize itobj=Gesetz()# Configure itobj.title='normal'# Convert legal referencesprint(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'}UsageClassGesetz__init__(providers: typing.Union[typing.Iterable[str], str])providerscontrols the providers (and their respective order) to be used, either some iterable (such aslistortuple) or a singlestr.Note:This defaults to all available providers, which is a good overall choice, simply because of the vast array of supported laws. However, possible values aregesetze,'dejure','buzer'and'lexparency'.gesetzify(string: str, callback: typing.Callable) -> strTransforms legal references into HTML link tagsNote:For more flexibility, you may use your owncallbackmethod as second parameter ofgesetzify. Callbacks are being passed there.Matchobject representing matched legal norms. This way, you could highlight them using<strong>tags instead of converting them intoatags. Default:obj.linkifyExample: Inside the callback function, thematchfor '§ 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 usingmatch.groupdict()).Note:For convenience, aMarkdowncallback is included and may be used like this:obj.gesetzify('your-text', obj.markdownify)Helpersanalyze(string: str) -> dictAnalyzes a single legal normextract(string: str) -> listExtracts legal norms as list of stringsroman2arabic(string: str)Converts roman numerals to arabic numerals (static method)ConfigurationThegesetzifycommand may be configured through the following options:obj.attributes (dict)Defines HTML attribute defaults. Default:{'target': '_blank'}obj.title (False|str)Controlstitleattribute. Default:FalsePossible values:light: abbreviated law (eg 'BGB')normal: complete law (eg 'Bürgerliches Gesetzbuch')full: official heading (eg '§ 1 Beginn der Rechtsfähigkeit')ContributingIf you want to get your hands dirty, this will download the repository and installpy-gesetzealong its dependencies inside a virtual environment, ready for action:# Clone repository & change directorygitclonehttps://codeberg.org/S1SYPHOS/py-gesetze&&cdpy-gesetze# Set up & activate virtualenvpoetryshell# Install dependenciespoetryinstallCreditsThis library is based on .... an adapted (and somewhat improved) version of thejura_regexregex package by Philipp Kiersch... an adapted (and somewhat modified) version of thegesetzecrawler package by Matej Grahovac.Special ThanksI'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 :)