Legislation

Codes

class authorityspoke.enactments.Code(filepath)

A code of legislation.

Could be a constitution, code of statutes, code of regulations, or collection of court rules.

Each instance of this class depends on an XML file containing the code, so every new XML format will require adding a method to this class to ingest it.

Parameters

filepath (Union[str, Path]) – the name of the file in the example_data/codes folder where the XML version of the code can be found.

__init__(filepath)

Set filepath parameter as attribute.

property jurisdiction

Get string representing the jurisdiction from within uri.

Return type

str

Returns

The abbreviation for the jurisdiction that enacted the Code, in USLM-like format.

e.g. us for U.S. federal laws, us-ca for California state laws.

property level

Get identifier for the Enactment type found in this Code.

Return type

str

Returns

“constitution”, “statute”, or “regulation”

property title

Provide “title” identifier for the Code’s XML.

Return type

str

Returns

the contents of an XML title element that describes the Code, if any. Otherwise returns a descriptive name that may not exactly appear in the XML.

property uri

Build a URI for the Code based on its XML metadata.

Note

This handles California state statutes only with a mockup, which can only refer to the Penal and Evidence Codes.

Return type

str

Returns

The United States Legislative Markup (USLM) identifier that describes the document as a whole, if available in the XML. Otherwise returns a pseudo-USLM identifier.

property xml

Get XML tree of legislative provisions.

Returns

A BeautifulSoup object created by parsing the Code’s XML file

format_uri_for_const(uri)

Convert uri to identifier for constitution sections.

Although the US Constitution is published in a format described as USML, its section identifier strings differ from those in USC USML documents in that they skip the jurisdiction and code fields, skip the initial slash character, start with the section field, and convert all remaining slashes to hyphens.

This will only remove the path to the current code if the current code is the same one referenced in the URI. So the example below assumes the current Code object has self.uri == "/us/const"

Parameters

uri (str) – an identifier in a format consistent with USC USML documents, e.g. /us/const/amendment/XIV/1

Return type

str

Returns

an identifier in a format found in the USLM version of the federal constitution, e.g. amendment-XIV-1

provision_effective_date(cite)

Give effective date for a provision within the Code.

So far this method only covers the US Constitution and it assumes that the XML format is United States Legislative Markup (USLM).

Parameters

cite (Union[TextQuoteSelector, str]) – a string or selector representing the XML element name for the the legislative provision within this Code.

Return type

date

Returns

the effective date of the cited provision

get_fed_const_section(path)

Get a section from a USLM identifier if self is the US Constitution.

Parameters

path (str) – a USLM path to a section of the US Constitution, with or without the part that identifies the Code, but without a namespace declaration.

Return type

BeautifulSoup

Returns

the XML section of self matching the path.

section_text(self, path)

Get the text of the section identified by a path.

Parameters

path (str) – a path string, in the format used for TextQuoteSelector objects, to the section with the text to be returned.

Return type

str

Returns

the text of a section of the Code.

select_text_from_interval(interval, path=None)

Select text as interval of section identified by path.

If path parameter is not given, selects an interval from the whole Code.

Parameters

interval (Tuple[int, int]) – the indices of the slice of the section text to be selected.

Para path

a path to the section that text should be selected from

Return type

Optional[str]

Returns

a slice of text from the section identified by path

select_text(selector)

Get text from the Code using a TextQuoteSelector.

Parameters

selector (TextQuoteSelector) – a selector referencing a text passage in the Code.

Note

When handling Code of Federal Regulation (CFR) Enactments, this can only select from the whole document or from Sections, not Subsections or any other level. Still hoping to be able to switch to a United States Legislative Markup (USLM)-like XML format for CFR.

Return type

Optional[str]

Returns

the text referenced by the selector, or None if the text can’t be found.

__repr__()

Return repr(self).

__str__()

Return str(self).

__weakref__

list of weak references to the object (if defined)

Enactments

class authorityspoke.enactments.Enactment(selector, code=None, regime=None, name=None)

A passage of legislative text.

May be used as support for a Rule. To retrieve the text, there needs to be an available method for identifying the correct XML element based on the section and subsection names, and each XML format used for any Code will require a different method.

Parameters
  • selector (TextQuoteSelector) – identifier for the place in the Code where the text can be found.

  • code (Optional[Code]) – the Code where this legislative text appears.

  • regime (Optional[Regime]) – a Regime with a Jurisdiction that has enacted the Code where this legislative text appears.

  • name (Optional[str]) – an identifier for this object, often used if the object needs to be referred to multiple times in the process of composing other Factor objects.

combine_text(other)

Create new Enactment with combined text of the source Enactments.

Parameters

other (Enactment) – another Enactment with text to combine with the text from self.

Return type

Optional[Enactment]

Returns

new Enactment with combined text of the source Enactments, or None if the Enactments can’t be combined.

text_interval(path=None)

Find integer indices for the quoted text.

Return type

Optional[Tuple[int, int]]

Returns

A tuple containing the lower and upper bounds of the text passage quoted in self.selector.exact within the XML section referenced in self.selector.path.

property effective_date

Give effective date for the Enactment.

Returns

the effective date of the text in this passage. Currently works only for the US Constitution.

property text

Get a passage from self’s Code with self’s TextQuoteSelector.

Returns

the full text of the cited passage from the XML.

means(other)

Find whether meaning of self is equivalent to that of other.

Self must be neither broader nor narrower than other, which means it must contain the same legislative text in the same Code from the same Jurisdiction

Note

You could always make the result False by comparing longer passages of text until you found a difference between the two sites in the text. Does this undercut the usefulness of the means method?

Return type

bool

Returns

whether self and other represent the same text issued by the same sovereign in the same level of Enactment.

__str__()

Return str(self).

__ge__(other)

Tells whether self implies other.

Note

Why does this method not require the same code.sovereign and code.level, especially considering that means() does?

Returns

Whether self “implies” other, which in this context means whether self contains at least all the same text as other.

__gt__(other)

Test whether self implies other without having same meaning.

Return type

bool

__weakref__

list of weak references to the object (if defined)