cobalt

Acts

class cobalt.act.Act(xml=None)

An act is a lightweight wrapper around an Akoma Ntoso 2.0 XML act document. It provides methods to help access and manipulate the underlying XML directly, in particular the metadata for the document.

The Act object provides quick access to certain sections of the document:

Variables:
  • rootlxml.objectify.ObjectifiedElement root of the XML document
  • metalxml.objectify.ObjectifiedElement meta element
  • bodylxml.objectify.ObjectifiedElement body element
__init__(xml=None)

Setup a new instance with the string in xml.

body_xml

The raw XML string of the body element of the document. When setting this property, XML must be rooted at a body element.

components()

Get an OrderedDict of component name to lxml.objectify.ObjectifiedElement objects.

expression_date

Date from the FRBRExpression element

expression_frbr_uri()

The FRBR Expression URI as a FrbrUri instance that uniquely identifies this document universally.

frbr_uri

The FRBR Work URI as a FrbrUri instance that uniquely identifies this document universally.

language

The 3-letter ISO-639-2 language code of this document

manifestation_date

Date from the FRBRManifestation element

nature

The nature of the document, such as an act, derived from frbr_uri. Read-only.

number

The act number, derived from frbr_uri. Read-only.

publication_date

Date of the publication

publication_name

Name of the publication in which this act was published

publication_number

Sequence number of the publication

title

Short title

work_date

Date from the FRBRWork element

year

The act year, derived from frbr_uri. Read-only.

FRBR URIs

class cobalt.uri.FrbrUri(country, locality, doctype, subtype, actor, date, number, work_component=None, language=None, expression_date=None, expression_component=None, expression_subcomponent=None, format=None)

An FRBR URI parser which understands Akoma Ntoso 3.0 FRBR URIs (IRIs) for works and expressions.

URIs can be parsed from a plain string using parse() or they can be constructed directly. URIs can be manipulated in-place once constructed, which is useful for turning a work-level URI into an expression or manifestation URI.

URIs can be transformed back to the string form of work, expression and manifestation URIs using the work_uri(), expression_uri() and manifestation_uri() methods.

Example:

>>> uri = FrbrUri.parse('/za-jhb/act/by-law/2003/public-health/eng:2015-01-01/main/part/A.xml')
>>> uri.country
'za'
>>> uri.locality
'jhb'
>>> uri.doctype
'act'
>>> uri.subtype
'by-law'
>>> uri.date
'2003'
>>> uri.number
'public-health'
>>> uri.language
'eng'
>>> uri.expression_date
':2015-01-01'
>>> uri.expression_component
'main'
>>> uri.expression_subcomponent
'part/A'
>>> uri.format
'xml'
>>> uri.work_uri()
'/za-jhb/act/by-law/2003/public-health'
>>> uri.expression_uri()
'/za-jhb/act/by-law/2003/public-health/eng:2015-01-01/main/part/A'
>>> uri.manifestation_uri()
'/za-jhb/act/by-law/2003/public-health/eng:2015-01-01/main/part/A.xml'
Variables:
  • country – two letter country code
  • locality – locality within the country, may be None
  • doctype – type of document (eg. act)
  • subtype – document subtype, may be None
  • actor – emenating actor, may be None
  • date – document data (str), YYYY[-MM[-DD]]
  • number – document number (str)
  • work_component – name of the work component, may be None
  • language – three-letter expression language code, may be None
  • expression_date – expression date (str), [@:]YYYY[-MM[-DD]], may be None
  • expression_component – name of the expression component, may be None
  • expression_subcomponent – name of the expression subcomponent, may be None
  • format – format extension, may be None
__init__(country, locality, doctype, subtype, actor, date, number, work_component=None, language=None, expression_date=None, expression_component=None, expression_subcomponent=None, format=None)

Initialize self. See help(type(self)) for accurate signature.

expression_uri(work_component=True)

String form of the expression URI.

manifestation_uri(work_component=True)

String form of the manifestation URI.

uri()

String form of the work URI, excluding the work component, if any.

work_uri(work_component=True)

String form of the work URI.

Rendering