A lightweight library for working with Akoma Ntoso Act documents
Cobalt is a lightweight Python library for working with Akoma Ntoso documents. It makes it easy to work with Akoma Ntoso documents, metadata and FRBR URIs.
It is lightweight because most operations are done on the XML document directly without intermediate objects. You still need to understand how Akoma Ntoso works.
$ pip install cobalt
Use it like this:
>>> from cobalt import Act >>> act = Act() >>> act.title = "Act 10 of 1980" >>> act.frbr_uri = "/za/act/1980-05-03/10" >>> act.frbr_uri.year '1980' >>> act.frbr_uri.date '1980-05-03' >>> act.frbr_uri.number '10' >>> act.frbr_uri.doctype 'act' >>> print act.to_xml() [ lots of xml ]
Clone the repo
Install development dependencies:
pip install -e .[dev]
Make your changes
nosetests && flake8 cobalt
Send a pull request
Releasing a New Version
Run the tests!
Update VERSION appropriately
Update the Change Log section in README.rst
Commit and tag:
git tag vX.X.X git push -u origin --tags
rm -rf build dist && python setup.py sdist bdist_wheel
Upload to PyPI:
twine upload dist/*
License and Copyright
Cobalt is licensed under the LPGL 3.0 license.
Cobalt is Copyright 2015-2020 AfricanLII.
- Allow setting of missing component names
- Better error handling when parsing malformed XML.
(replaced by 4.0.2)
- Support AKN 3.0 namespaces
- Produce URIs with akn prefix by default (backwards compatibility maintained)
- Support all Akoma Ntoso document types
- Start FRBR URI work component with ! (eg. !main)
- FRBRcountry uses full country code from the FRBR URI
- FRBRnumber uses number portion from FRBR URI
- FRBRdate for FRBRWork contains the date portion of the FRBR URI
- Include AKN 3.0 schema and support for validating against the schema
- The elements returned by components() are now attachment or component elements, not the inner doc
- FIX issue where a four-digit number in an FRBR URI confuses the parser
- Replace arrow with iso8601, avoiding arrow issue 612
- Python 3.6 and 3.7 support
- Drop support for Python 2.x
- FIX don’t mistake numbers in uris with subtypes and numeric numbers as actors
- FIX link to GitHub
- Unicode literals when parsing FRBR URIs
- FIX don’t strip empty whitespace during objectify.fromstring
- FIX don’t pretty-print XML, it introduces meaningful whitespace
- FIX FrbrUri clone bug when a URI had a language.
- Move table of contents, render and other locale (legal tradition) specific functionality out of Cobalt.
- FIX bug that returned the incorrect language when extracting a document’s expression URI.
- Inject original img src as data-src
- Support for i18n in XSLT files, including all 11 South African languages from myconstitution.co.za
- Support for images
- Change how XSLT params are passed to the renderer
- Add expression_frbr_uri method to Act class
- When rendering HTML, ensure primary container elements and schedules have appropriate ids
- When rendering HTML, scope component/schedule ids to ensure they’re unique
- Render ref elements as HTML a elements
- Optionally prepend a resolver URL before a elements
- Convert EOL elements to BR when changing XML to HTML
- Support dates before 1900. Contributed by rkunal.
- lifecycle and identification meta elements now have a configurable source attribute
- TOCElement items now include a best-effort title
- Use HTML5 semantic elements section and article when generating HTML for acts
- FIX use schedule FRBRalias as heading
- Transforming XML to HTML now includes all attributes as data- attributes
- Refactor TOC helpers into own file
- Fix .format in FrbrUri
- first release
Release history Release notifications | RSS feed
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size||File type||Python version||Upload date||Hashes|
|Filename, size cobalt-4.1.0-py3-none-any.whl (73.4 kB)||File type Wheel||Python version py3||Upload date||Hashes View|
|Filename, size cobalt-4.1.0.tar.gz (72.8 kB)||File type Source||Python version None||Upload date||Hashes View|