Schemas

class authorityspoke.io.schemas.ExpandableSchema(*, only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None)
get_from_mentioned(data, **kwargs)

Replaces data to load with any object with same name in “mentioned”.

remove_anchors_field(data, **kwargs)

Remove field that may have been used to link objects to Opinion text.

wrap_single_element_in_list(data, many_element)

Make a specified field a list if it isn’t already a list.

class authorityspoke.io.schemas.OpinionSchema(*, only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None)
class authorityspoke.io.schemas.CaseCitationSchema(*, only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None)
class authorityspoke.io.schemas.DecisionSchema(*, only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None)
class authorityspoke.io.schemas.SelectorSchema(*, only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None)
expand_shorthand(data, **kwargs)

This will repeat an operation that already happened if expand_anchor_shorthand() was already called in load_holdings().

Return type

Dict[str, str]

class authorityspoke.io.schemas.EnactmentSchema(*, only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None)
move_selector_fields(data, **kwargs)

Nest fields used for SelectorSchema model.

If the fields are already nested, they need not to be moved.

The fields can only be moved into a “selector” field with a dict value, not a “selectors” field with a list value.

authorityspoke.io.schemas.read_quantity(value)

Create pint quantity object from text.

See pint tutorial

Parameters

quantity – when a string is being parsed for conversion to a Predicate, this is the part of the string after the equals or inequality sign.

Return type

Union[float, int, Quantity]

Returns

a Python number object or a Quantity object created with pint.UnitRegistry.

authorityspoke.io.schemas.dump_quantity(obj)

Convert quantity to string if it’s a pint ureg.Quantity object.

Return type

Union[float, int, str, None]

class authorityspoke.io.schemas.PredicateSchema(*, only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None)
class authorityspoke.io.schemas.EntitySchema(*, only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None)
class authorityspoke.io.schemas.FactSchema(*, only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None)
get_references_from_mentioned(content, context_factors=None, placeholder='{}')

Retrieve known context Factors for new Fact.

Parameters
  • content (str) – the content for the Fact’s Predicate

  • mentioned – list of Factors with names that could be referenced in content

  • placeholder (str) – a string to replace the names of referenced Factors in content

Return type

Tuple[str, List[Dict]]

Returns

the content string with any referenced Factors replaced by placeholder, and a list of referenced Factors in the order they appeared in content.

format_data_to_load(data, **kwargs)

Prepare RawFact to load, replacing name references with full objects.

Unlike the name_index.collect_mentioned() function, this function can’t add any entries to the “mentioned” name index (due to limitations in the Marshmallow serialization library). That means all shorthand references to factors need to have been expanded before using the schema to load new objects.

Parameters

data (Dict[str, Union[Dict[str, Union[str, bool]], Sequence[Any], str, bool]]) – a dict representing a Fact

Return type

Dict[str, Union[Dict[str, Union[str, bool]], Sequence[Any], str, bool]]

Returns

a normalized dict representing a Facts with name references expanded

class authorityspoke.io.schemas.ExhibitSchema(*, only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None)
class authorityspoke.io.schemas.PleadingSchema(*, only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None)
class authorityspoke.io.schemas.AllegationSchema(*, only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None)
class authorityspoke.io.schemas.EvidenceSchema(*, only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None)
class authorityspoke.io.schemas.FactorSchema(*, only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None)
pre_load(data, **kwargs)

Preprocess data before selecting from among the linked schema options.

To be replaced by a function that would have used the @pre_load decorator, if it was available for OneOfSchema objects.

Return type

Dict[str, Union[Dict[str, Union[str, bool]], Sequence[Any], str, bool]]

get_obj_type(obj)

Returns name of object schema

Return type

str

class authorityspoke.io.schemas.ProcedureSchema(*, only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None)
class authorityspoke.io.schemas.RuleSchema(*, only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None)
class authorityspoke.io.schemas.HoldingSchema(*, only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None)
nest_fields_inside_rule(data)

Nest fields inside “rule” and “procedure”, if not already nested.

Return type

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]]

authorityspoke.io.schemas.get_schema_for_item(item)

Find the Marshmallow schema for an AuthoritySpoke object.

Return type

Schema