YAML Schemas

Marshmallow schemas for loading AuthoritySpoke objects from YAML.

Intended for use with human-generated files. Some shortened syntax is allowed.

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

Base schema for classes that can be cross-referenced by name in input JSON.

get_from_mentioned(data, **kwargs)

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

consume_type_field(data, **kwargs)

Verify that type field is correct and then get rid of it.

wrap_single_element_in_list(data, many_element)

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

format_data_to_load(data, **kwargs)

Expand data if it was just a name reference in the JSON input.

Return type

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

make_object(data, **kwargs)

Make AuthoritySpoke object out of whatever data has been loaded.

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

Replace data to load with any object with same name in “enactment_index”.

format_data_to_load(data, **kwargs)

Prepare Enactment to load.

class authorityspoke.io.schemas_yaml.PredicateSchema(*, only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None)

Schema for statements, separate from any claim about their truth or who asserts them.

split_quantity_from_content(content)

Find any reference to a quantity in the content text.

Return type

Tuple[str, Optional[str], Union[Quantity, int, float, None]]

normalize_comparison(data, **kwargs)

Reduce the number of possible symbols to represent comparisons.

Return type

Dict[str, Union[str, bool]]

format_data_to_load(data, **kwargs)

Expand any reference to a quantity in the content text.

Return type

Dict[str, Union[str, bool]]

class authorityspoke.io.schemas_yaml.EntitySchema(*, only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None)

Schema for Entities, which shouldn’t be at the top level of a FactorGroup.

class authorityspoke.io.schemas_yaml.FactSchema(*, only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None)

Schema for Facts, which may contain arbitrary levels of nesting.

get_references_from_mentioned(content, terms=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

make_object(data, **kwargs)

Make Fact.

Return type

Fact

class authorityspoke.io.schemas_yaml.ExhibitSchema(*, only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None)

Schema for an object that may embody a statement.

make_object(data, **kwargs)

Make Exhibit.

Return type

Exhibit

class authorityspoke.io.schemas_yaml.PleadingSchema(*, only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None)

Schema for a document to link Allegations to.

class authorityspoke.io.schemas_yaml.AllegationSchema(*, only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None)

Schema for an Allegation of a Fact.

class authorityspoke.io.schemas_yaml.EvidenceSchema(*, only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None)

Schema for an Exhibit and a reference to the Fact it would support.

class authorityspoke.io.schemas_yaml.FactorSchema(*, only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None)

Schema that directs data to “one of” the other schemas.

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)

Return name of object schema.

Return type

str

class authorityspoke.io.schemas_yaml.ProcedureSchema(*, only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None)

Schema for Procedure; does not require separate TermSequence schema.

“FactorSchema, many=True” is an equivalent of a TermSequence.

format_data_to_load(data, **kwargs)

Handle omission of brackets around single item.

class authorityspoke.io.schemas_yaml.RuleSchema(*, only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None)

Schema for Holding; can also hold Procedure fields.

format_data_to_load(data, **kwargs)

Prepare to load Rule.

Return type

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

make_object(data, **kwargs)

Make AuthoritySpoke object out of whatever data has been loaded.

class authorityspoke.io.schemas_yaml.HoldingSchema(*, only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None)

Schema for Holding; can also hold Rule and Procedure fields.

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

format_data_to_load(data, **kwargs)

Prepare to load Holding.

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

class authorityspoke.io.schemas_yaml.NamedAnchors(name, anchors)
name: nettlesome.factors.Factor

Alias for field number 0

anchors: List[anchorpoint.textselectors.TextQuoteSelector]

Alias for field number 1

class authorityspoke.io.schemas_yaml.NamedAnchorsSchema(*, only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None)
format_data_to_load(data, **kwargs)

Expand data if it was just a name reference in the JSON input.

class authorityspoke.io.schemas_yaml.AnchoredEnactments(enactment, anchors)
enactment: legislice.enactments.Enactment

Alias for field number 0

anchors: List[anchorpoint.textselectors.TextQuoteSelector]

Alias for field number 1

class authorityspoke.io.schemas_yaml.AnchoredEnactmentsSchema(*, only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None)
format_data_to_load(data, **kwargs)

Expand data if it was just a name reference in the JSON input.

class authorityspoke.io.schemas_yaml.AnchoredHoldingsSchema(*, only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None)
format_data_to_load(data, **kwargs)

Expand data if it was just a name reference in the JSON input.

Return type

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

make_object(data, **kwargs)

Make AuthoritySpoke object out of whatever data has been loaded.

Return type

AnchoredHoldings