Legislation

Codes

class authorityspoke.enactments.Code(xml, title, uri)

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
  • xml – A BeautifulSoup object created by parsing the Code’s XML file

  • title (str) – A name for the Code that may have been found in an XML title element. For larger codes like the United States Code, this should identify the title number, and the Code object will contain text only from that title.

  • uri (str) – The United States Legislative Markup (USLM) identifier that describes the document as a whole, if available. Otherwise, should be a pseudo-USLM identifier.

__init__(xml, title, uri)

Link an entire XML tree to the Code.

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 level of legislation for this Code, e.g. “statute”.

Return type

str

Returns

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

text_interval(selector=None, path='')

Find integer indices for the quoted text.

Return type

Optional[TextPositionSelector]

Returns

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

provision_effective_date(cite)

Give effective date for a provision within the Code.

Return type

date

get_exact_from_source(source, selector)

Use source to find text for exact parameter.

Parameters
  • source (str) – path to a cited section or node, which may contain subsections

  • selector (TextQuoteSelector) – selector for the cited text passage within the cited node

Return type

Optional[str]

make_docpath(path='')

Remove Code identifier from path to get a path relative to the document.

Return type

str

get_sections(path='')

Get sections identified by a path, if present in the Code.

Parameters

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

Return type

Optional[BeautifulSoup]

Returns

the text of a section of the Code.

static section_text(passages)

Get the text of legislative sections from XML elements.

Parameters

passages (Sequence[BeautifulSoup]) – a sequence of XML elements with text to join

Return type

str

Returns

the text of the XML elements.

section_text_from_path(path='')

Get the text of legislative sections from a path identifier.

Parameters

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

Return type

str

Returns

the text of the XML elements.

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 (TextPositionSelector) – 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(path, selector=None)

Get text from the Code using a TextQuoteSelector.

Parameters

selector (Optional[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(source, selector=None, code=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 (Optional[Union[TextQuoteSelector, TextPositionSelector]]) – identifier for the section of a Code where the text can be found.

  • selector – identifier for the part of the section being cited

  • code (Optional[Code]) – 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.

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 interval

Return TextPositionSelector for cited part of the Enactment section.

property text

Get 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)