Readers¶
Converting simple structured data from XML or JSON into authorityspoke objects.
These functions will usually be called by functions from the io.loaders module after they import some data from a file.
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
- 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.
Provide “title” identifier for the
Code
XML.- Return type
- Returns
the contents of an XML
title
element that describes theCode
, if any. Otherwise returns a descriptive name that may not exactly appear in the XML.
Determine if the Code XML has the USLM schema.
- Return type
Create a new
Enactment
object using imported JSON data.The new
Enactment
can be composed from aCode
referenced in theregime
parameter.- Parameters
record (
Dict
[str
,Union
[str
,List
[Union
[str
,Dict
[str
,str
]]]]]) –dict
with string fields from JSON for constructing newEnactment
code (
Optional
[Code
]) – theCode
that is the source for thisEnactment
regime (
Optional
[Regime
]) – theRegime
where theCode
that is the source for thisEnactment
can be found, or where it should be added
- Return type
- Returns
a new
Enactment
object, optionally with text links.
Create a new
Enactment
object using imported JSON data.The new
Enactment
can be composed from aCode
referenced in theregime
parameter.- Parameters
record (
List
[Dict
[str
,Union
[str
,List
[Union
[str
,Dict
[str
,str
]]]]]]) – sequence ofdict
s with string fields from JSON for constructing newEnactment
scode (
Optional
[Code
]) – aCode
that is the source for everyEnactment
to be loaded, if they all come from the sameCode
regime (
Optional
[Regime
]) – theRegime
where theCode
s that are the source for thisEnactment
can be found, or where it should be added
- Return type
- Returns
a list of new
Enactment
objects, optionally with text links.
Construct a
Fact
after loading a dict from JSON.
Turn fields from JSON into a
Factor
object.
Turn fields from JSON into a
Factor
object.
Create new
Holding
object from simple datatypes from JSON input.Will yield multiple items if
exclusive: True
is present inrecord
.- Parameters
record (
Dict
[str
,Union
[Dict
[str
,Union
[Dict
[str
,Sequence
[Dict
[str
,Union
[Dict
[str
,Union
[str
,bool
]],Sequence
[Any
],str
,bool
]]]],Sequence
[Dict
[str
,Union
[str
,List
[Union
[str
,Dict
[str
,str
]]]]]],str
,bool
]],str
,bool
]]) – dict of values for constructingHolding
regime (
Optional
[Regime
]) – Collection ofJurisdiction
s and correspondingCode
s for discoveringEnactment
s to reference in the newHolding
.many – if True, record represents a list of
Holding
s rather than just one.
- Return type
- Returns
New
Holding
, and an updated dictionary with mentionedFactor
s as keys and theirTextQuoteSelector
s as values.
Alias for field number 0
Alias for field number 1
Alias for field number 2
Load a list of
Holdings
s from JSON, with optional text links.- Parameters
record (
List
[Dict
[str
,Union
[Dict
[str
,Union
[Dict
[str
,Sequence
[Dict
[str
,Union
[Dict
[str
,Union
[str
,bool
]],Sequence
[Any
],str
,bool
]]]],Sequence
[Dict
[str
,Union
[str
,List
[Union
[str
,Dict
[str
,str
]]]]]],str
,bool
]],str
,bool
]]]) – a list of dicts representing holdings, in the JSON input format- Parame regime
A collection of
Jurisdiction
s and theCode
s that have been enacted in each. Used for constructingEnactment
s referenced byHolding
s.- Return type
- Returns
a list of
Holding
objects, optionally with an index matchingFactor
s to selectors.
Create and return one or more
Opinion
objects from a dict API response.Relies on the JSON format from the Caselaw Access Project API.
This function is a more convenient way to call read_opinions with an entire case from the CAP API as a single parameter.