Skip to main content

A lightweight library for working with Akoma Ntoso Act documents

Project description

https://laws.africa/img/icons/cobalt.png https://badge.fury.io/py/cobalt.svg

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.

Read the full documentation at cobalt.readthedocs.io.

Quickstart

Install using:

$ 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 ]

Contributing

  1. Clone the repo

  2. Install development dependencies:

    pip install -e .[dev]
  3. Make your changes

  4. Run tests:

    nosetests && flake8 cobalt
  5. Send a pull request

Releasing a New Version

  1. Run the tests!

  2. Update VERSION appropriately

  3. Update the Change Log section in README.rst

  4. Commit and tag:

    git tag vX.X.X
    git push -u origin --tags
  5. Build artefacts:

    rm -rf build dist && python setup.py sdist bdist_wheel
  6. Upload to PyPI:

    twine upload dist/*

Change Log

7.0.0

  • Rename DebateReport to Debate

6.1.0

  • Add new schemas.AkomaNtoso30 class with basic schema information

6.0.0

  • Add support for portions, such as ~chp_2

  • Remove non-standard support for expression component and subcomponent

  • Remove non-standard legacy support for work components without !

5.0.0

  • Allow slashes in FRBR URI work component names

  • Setting expression and manifestation dates updates attachments and other components

  • Don’t include Cobalt-specific <references> element in attachments

  • Cascade changes to FRBRlanguage into attachments

  • Don’t hardcode source

  • Don’t set contains="originalVersion" since it is the default value for that attribute.

  • Use 0001-01-01 as a placeholder date for publication, amendment and repeal events with null dates

4.1.1

  • Change eIds of content produced by empty_document_content()

4.1.0

  • Allow setting of missing component names

4.0.2

  • Better error handling when parsing malformed XML.

4.0.1

(replaced by 4.0.2)

4.0.0

  • 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

3.1.1

  • FIX issue where a four-digit number in an FRBR URI confuses the parser

3.1.0

3.0.0

  • Python 3.6 and 3.7 support

  • Drop support for Python 2.x

2.2.0

  • FIX don’t mistake numbers in uris with subtypes and numeric numbers as actors

  • FIX link to GitHub

  • Unicode literals when parsing FRBR URIs

2.1.0

  • FIX don’t strip empty whitespace during objectify.fromstring

2.0.0

  • FIX don’t pretty-print XML, it introduces meaningful whitespace

1.0.1

  • FIX FrbrUri clone bug when a URI had a language.

1.0.0

  • 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.

0.3.2

  • Inject original img src as data-src

0.3.1

  • Support for i18n in XSLT files, including all 11 South African languages from myconstitution.co.za

0.3.0

  • Support for images

  • Change how XSLT params are passed to the renderer

  • Add expression_frbr_uri method to Act class

0.2.1

  • When rendering HTML, ensure primary container elements and schedules have appropriate ids

0.2.0

  • When rendering HTML, scope component/schedule ids to ensure they’re unique

0.1.11

  • Render ref elements as HTML a elements

  • Optionally prepend a resolver URL before a elements

0.1.10

  • Convert EOL elements to BR when changing XML to HTML

0.1.9

  • Support dates before 1900. Contributed by rkunal.

0.1.8

  • lifecycle and identification meta elements now have a configurable source attribute

0.1.7

  • TOCElement items now include a best-effort title

0.1.6

  • Use HTML5 semantic elements section and article when generating HTML for acts

0.1.5

  • FIX use schedule FRBRalias as heading

0.1.4

  • Transforming XML to HTML now includes all attributes as data- attributes

0.1.3

  • Refactor TOC helpers into own file

  • Fix .format in FrbrUri

0.1.1

  • first release

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

cobalt-7.0.0.tar.gz (74.4 kB view details)

Uploaded Source

Built Distribution

cobalt-7.0.0-py3-none-any.whl (74.7 kB view details)

Uploaded Python 3

File details

Details for the file cobalt-7.0.0.tar.gz.

File metadata

  • Download URL: cobalt-7.0.0.tar.gz
  • Upload date:
  • Size: 74.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.8.14

File hashes

Hashes for cobalt-7.0.0.tar.gz
Algorithm Hash digest
SHA256 c26faa27eb359ee3f0926306a5f3b378882c5431c42815c1c625b1d6f64d7d5d
MD5 b3a8549867969ae783b83778ce317887
BLAKE2b-256 1d93dc16b1286389e2cc2fef2e3aa869c3971a260400d555d5032a189af53c68

See more details on using hashes here.

File details

Details for the file cobalt-7.0.0-py3-none-any.whl.

File metadata

  • Download URL: cobalt-7.0.0-py3-none-any.whl
  • Upload date:
  • Size: 74.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.8.14

File hashes

Hashes for cobalt-7.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b1121b2fbb995670589c7530ac231a0411e20faa6c4469f97825f2ec8c5f0371
MD5 9b3fe30753f7f9bb6dbfbb125fb83529
BLAKE2b-256 6a8744d15f5ea0461e05dec32ecc994bba2d8fad8fae3d2accfe183ae0209d01

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