Skip to main content

A lightweight library for working with Akoma Ntoso Act documents

Project description

https://badge.fury.io/py/cobalt.svg https://travis-ci.org/OpenUpSA/cobalt.svg

Cobalt is a lightweight Python library for working with Akoma Ntoso Act documents. It makes it easy to work with Akoma Ntoso metadata, FRBR URIs and generate Tables of Contents for a document.

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

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/10"
>>> act.year
'1980'
>>> act.number
'10'
>>> 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 push to github

  5. Release to PyPI:

    python setup.py sdist bdist_wheel upload

Change Log

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-2.0.0.tar.gz (11.1 kB view details)

Uploaded Source

Built Distribution

cobalt-2.0.0-py2-none-any.whl (9.8 kB view details)

Uploaded Python 2

File details

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

File metadata

  • Download URL: cobalt-2.0.0.tar.gz
  • Upload date:
  • Size: 11.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Python-urllib/2.7

File hashes

Hashes for cobalt-2.0.0.tar.gz
Algorithm Hash digest
SHA256 eb096b4e97af75072364107825cac163380ac801bce1b78bb62c5589bfb6628b
MD5 72e9a9a047976a42179e2554747535a9
BLAKE2b-256 1981323fccaa60be601c4a32284b3d563741f2fe1468b86269a6c9f91d2ab350

See more details on using hashes here.

File details

Details for the file cobalt-2.0.0-py2-none-any.whl.

File metadata

  • Download URL: cobalt-2.0.0-py2-none-any.whl
  • Upload date:
  • Size: 9.8 kB
  • Tags: Python 2
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Python-urllib/2.7

File hashes

Hashes for cobalt-2.0.0-py2-none-any.whl
Algorithm Hash digest
SHA256 cf96cc576b9c54966e252e3dee8a0191194624a425dd3bdb06ab67974d0899f6
MD5 3abcfb9e61b7e61ead05c60a41ea097e
BLAKE2b-256 8a04953c35270c0c2312aabf4c372d2cfd4bb0a0ed5994d4461d14cd503ae09f

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