syn.schema.b package

Submodules

syn.schema.b.sequence module

Tools for representing sets of sequences via sequence operators and sets of sequence items. The main idea is that a set of sequences is the result of a (flattened) Cartesian product over a sequence of sets.

class syn.schema.b.sequence.SchemaNode(**kwargs)

Bases: syn.tree.b.node.Node

Keyword-Only Arguments:

_id [Optional]: int
Integer id of the node
_list: list
Child nodes
_name [Optional]: basestring
Name of the node (for display purposes)
_node_count: int
The number of nodes in the subtreerooted by this node.
_parent [Optional]: Node
Parent of this node
set [Optional]: SetNode
Internal set representation

Class Options:

  • args: ()
  • autodoc: True
  • coerce_args: False
  • descendant_exclude: ()
  • id_equality: False
  • init_validate: False
  • make_hashable: False
  • make_type_object: True
  • max_len: None
  • min_len: None
  • must_be_root: False
  • optional_none: True
  • register_subclasses: False
  • repr_template:
  • coerce_hooks: ()
  • create_hooks: ()
  • init_hooks: ()
  • init_order: ()
  • metaclass_lookup: (‘coerce_hooks’, ‘init_hooks’, ‘create_hooks’, ‘setstate_hooks’)
  • setstate_hooks: ()

Aliases:

  • _list: _children, elems

Groups:

  • _all: _id, _list, _name, _node_count, _parent, set
  • copy_copy: _list
  • hash_exclude: _parent
  • generate_exclude: _node_count, _parent
  • _internal: _id, _list, _name, _node_count, _parent, set
  • repr_exclude: _list, _parent
  • eq_exclude: _parent
  • getstate_exclude: _parent
  • str_exclude: _id, _list, _name, _node_count, _parent
elems
class syn.schema.b.sequence.Set([set, ]**kwargs)

Bases: syn.schema.b.sequence.SchemaNode

Positional Arguments:

set [Optional]: SetNode
Internal set representation

Keyword-Only Arguments:

_id [Optional]: int
Integer id of the node
_list: list
Child nodes
_name [Optional]: basestring
Name of the node (for display purposes)
_node_count: int
The number of nodes in the subtreerooted by this node.
_parent [Optional]: Node
Parent of this node

Class Options:

  • args: (‘set’,)
  • autodoc: True
  • coerce_args: False
  • descendant_exclude: ()
  • id_equality: False
  • init_validate: False
  • make_hashable: False
  • make_type_object: True
  • max_len: 0
  • min_len: None
  • must_be_root: False
  • optional_none: True
  • register_subclasses: False
  • repr_template:
  • coerce_hooks: ()
  • create_hooks: ()
  • init_hooks: ()
  • init_order: ()
  • metaclass_lookup: (‘coerce_hooks’, ‘init_hooks’, ‘create_hooks’, ‘setstate_hooks’)
  • setstate_hooks: ()

Aliases:

  • _list: _children, elems

Groups:

  • _all: _id, _list, _name, _node_count, _parent, set
  • copy_copy: _list
  • hash_exclude: _parent
  • generate_exclude: _node_count, _parent
  • _internal: _id, _list, _name, _node_count, _parent, set
  • repr_exclude: _list, _parent
  • eq_exclude: _parent
  • getstate_exclude: _parent
  • str_exclude: _id, _list, _name, _node_count, _parent
match(seq, **kwargs)
class syn.schema.b.sequence.Type([set, ]**kwargs)

Bases: syn.schema.b.sequence.Set

Positional Arguments:

set [Optional]: SetNode
Internal set representation

Keyword-Only Arguments:

_id [Optional]: int
Integer id of the node
_list: list
Child nodes
_name [Optional]: basestring
Name of the node (for display purposes)
_node_count: int
The number of nodes in the subtreerooted by this node.
_parent [Optional]: Node
Parent of this node

Class Options:

  • args: (‘set’,)
  • autodoc: True
  • coerce_args: False
  • descendant_exclude: ()
  • id_equality: False
  • init_validate: False
  • make_hashable: False
  • make_type_object: True
  • max_len: 0
  • min_len: None
  • must_be_root: False
  • optional_none: True
  • register_subclasses: False
  • repr_template:
  • coerce_hooks: ()
  • create_hooks: ()
  • init_hooks: ()
  • init_order: ()
  • metaclass_lookup: (‘coerce_hooks’, ‘init_hooks’, ‘create_hooks’, ‘setstate_hooks’)
  • setstate_hooks: ()

Aliases:

  • _list: _children, elems

Groups:

  • _all: _id, _list, _name, _node_count, _parent, set
  • copy_copy: _list
  • hash_exclude: _parent
  • generate_exclude: _node_count, _parent
  • _internal: _id, _list, _name, _node_count, _parent, set
  • repr_exclude: _list, _parent
  • eq_exclude: _parent
  • getstate_exclude: _parent
  • str_exclude: _id, _list, _name, _node_count, _parent
class syn.schema.b.sequence.Or(**kwargs)

Bases: syn.schema.b.sequence.SchemaNode

Keyword-Only Arguments:

_id [Optional]: int
Integer id of the node
_list: list
Child nodes
_name [Optional]: basestring
Name of the node (for display purposes)
_node_count: int
The number of nodes in the subtreerooted by this node.
_parent [Optional]: Node
Parent of this node
set [Optional]: SetNode
Internal set representation

Class Options:

  • args: ()
  • autodoc: True
  • coerce_args: False
  • descendant_exclude: ()
  • id_equality: False
  • init_validate: False
  • make_hashable: False
  • make_type_object: True
  • max_len: None
  • min_len: 2
  • must_be_root: False
  • optional_none: True
  • register_subclasses: False
  • repr_template:
  • coerce_hooks: ()
  • create_hooks: ()
  • init_hooks: ()
  • init_order: ()
  • metaclass_lookup: (‘coerce_hooks’, ‘init_hooks’, ‘create_hooks’, ‘setstate_hooks’)
  • setstate_hooks: ()

Aliases:

  • _list: _children, elems

Groups:

  • _all: _id, _list, _name, _node_count, _parent, set
  • copy_copy: _list
  • hash_exclude: _parent
  • generate_exclude: _node_count, _parent
  • _internal: _id, _list, _name, _node_count, _parent, set
  • repr_exclude: _list, _parent
  • eq_exclude: _parent
  • getstate_exclude: _parent
  • str_exclude: _id, _list, _name, _node_count, _parent
generate_set(**kwargs)
match(seq, **kwargs)
class syn.schema.b.sequence.Repeat(**kwargs)

Bases: syn.schema.b.sequence.SchemaNode

Keyword-Only Arguments:

_id [Optional]: int
Integer id of the node
_list: list
Child nodes
_name [Optional]: basestring
Name of the node (for display purposes)
_node_count: int
The number of nodes in the subtreerooted by this node.
_parent [Optional]: Node
Parent of this node
greedy (default = True): bool
Match as much as we can if True
lb (default = 0): int
Minimum number of times to repeat
set [Optional]: SetNode
Internal set representation
ub [Optional]: int
Maximum number of times to repeat

Class Options:

  • args: ()
  • autodoc: True
  • coerce_args: False
  • descendant_exclude: ()
  • id_equality: False
  • init_validate: False
  • make_hashable: False
  • make_type_object: True
  • max_len: 1
  • min_len: 1
  • must_be_root: False
  • optional_none: True
  • register_subclasses: False
  • repr_template:
  • coerce_hooks: ()
  • create_hooks: ()
  • init_hooks: ()
  • init_order: ()
  • metaclass_lookup: (‘coerce_hooks’, ‘init_hooks’, ‘create_hooks’, ‘setstate_hooks’)
  • setstate_hooks: ()

Aliases:

  • _list: _children, elems

Groups:

  • _all: _id, _list, _name, _node_count, _parent, greedy, lb, set, ub
  • copy_copy: _list
  • hash_exclude: _parent
  • generate_exclude: _node_count, _parent
  • _internal: _id, _list, _name, _node_count, _parent, set
  • repr_exclude: _list, _parent
  • eq_exclude: _parent
  • getstate_exclude: _parent
  • str_exclude: _id, _list, _name, _node_count, _parent
A

itemgetter(item, ...) –> itemgetter object

Return a callable object that fetches the given item(s) from its operand. After f = itemgetter(2), the call f(r) returns r[2]. After g = itemgetter(2, 5, 3), the call g(r) returns (r[2], r[5], r[3])

generate_set(**kwargs)
match(seq, **kwargs)
validate()
class syn.schema.b.sequence.Sequence(**kwargs)

Bases: syn.schema.b.sequence.SchemaNode

Denotes a sequence. The only SchemaNode that can denote a sequence.

Keyword-Only Arguments:

_id [Optional]: int
Integer id of the node
_list: list
Child nodes
_name [Optional]: basestring
Name of the node (for display purposes)
_node_count: int
The number of nodes in the subtreerooted by this node.
_parent [Optional]: Node
Parent of this node
set [Optional]: SetNode
Internal set representation

Class Options:

  • args: ()
  • autodoc: True
  • coerce_args: False
  • descendant_exclude: ()
  • id_equality: False
  • init_validate: True
  • make_hashable: False
  • make_type_object: True
  • max_len: None
  • min_len: None
  • must_be_root: False
  • optional_none: True
  • register_subclasses: False
  • repr_template:
  • coerce_hooks: ()
  • create_hooks: ()
  • init_hooks: ()
  • init_order: ()
  • metaclass_lookup: (‘coerce_hooks’, ‘init_hooks’, ‘create_hooks’, ‘setstate_hooks’)
  • setstate_hooks: ()

Aliases:

  • _list: _children, elems

Groups:

  • _all: _id, _list, _name, _node_count, _parent, set
  • copy_copy: _list
  • hash_exclude: _parent
  • generate_exclude: _node_count, _parent
  • _internal: _id, _list, _name, _node_count, _parent, set
  • repr_exclude: _list, _parent
  • eq_exclude: _parent
  • getstate_exclude: _parent
  • str_exclude: _id, _list, _name, _node_count, _parent
enumerate(**kwargs)

Iterate through all possible sequences (lists). By default, will stop after 50 items have been yielded. This value can be change by supplying a different value via the max_enumerate kwarg.

generate_set(**kwargs)
get_one(**kwargs)

Returns one possible sequence (list). May return the same value on multiple invocations.

match(seq, **kwargs)

If the schema matches seq, returns a list of the matched objects. Otherwise, returns MatchFailure instance.

sample(**kwargs)

Returns one possible sequence (list). The selection is randomized.

validate()
class syn.schema.b.sequence.Match(**kwargs)

Bases: syn.base.b.wrapper.ListWrapper

Keyword-Only Arguments:

_list: list
The wrapped list

Class Options:

  • args: ()
  • autodoc: True
  • coerce_args: False
  • id_equality: False
  • init_validate: False
  • make_hashable: False
  • make_type_object: True
  • max_len: None
  • min_len: None
  • optional_none: False
  • register_subclasses: False
  • repr_template:
  • coerce_hooks: ()
  • create_hooks: ()
  • init_hooks: ()
  • init_order: ()
  • metaclass_lookup: (‘coerce_hooks’, ‘init_hooks’, ‘create_hooks’, ‘setstate_hooks’)
  • setstate_hooks: ()

Groups:

  • _all: _list
  • copy_copy: _list
  • _internal: _list
  • str_exclude: _list
class syn.schema.b.sequence.MatchFailure(**kwargs)

Bases: syn.base.b.base.Base

Keyword-Only Arguments:

fails [Optional]: list
List of sub-failures
message: basestring
Reason for failure
seq: IterableList
The sequence that failed to match

Class Options:

  • args: ()
  • autodoc: True
  • coerce_args: False
  • id_equality: False
  • init_validate: True
  • make_hashable: False
  • make_type_object: True
  • optional_none: False
  • register_subclasses: False
  • repr_template:
  • coerce_hooks: ()
  • create_hooks: ()
  • init_hooks: ()
  • init_order: ()
  • metaclass_lookup: (‘coerce_hooks’, ‘init_hooks’, ‘create_hooks’, ‘setstate_hooks’)
  • setstate_hooks: ()

Groups:

  • _all: fails, message, seq
exception syn.schema.b.sequence.MatchFailed(msg, seq, fails=None)

Bases: exceptions.Exception

failure()

Module contents