reconfigure.items.bound

class reconfigure.items.bound.BoundCollection(node, item_class, selector=<function <lambda> at 0x251ee60>)[source]

Binds a list-like object to a set of nodes

Parameters:
  • node – target node (its children will be bound)
  • item_classBoundData class for items
  • selectorlambda x: bool, used to filter out a subset of nodes
append(item)[source]
insert(index, item)[source]
pop(index)[source]
rebuild()[source]

Discards cached collection and rebuilds it from the nodes

remove(item)[source]
to_dict()[source]
to_json()[source]
class reconfigure.items.bound.BoundData(node=None, **kwargs)[source]

Binds itself to a node.

bind_* classmethods should be called on module-level, after subclass declaration.

Parameters:
  • node – all bindings will be relative to this node
  • kwargs – if node is None, template(**kwargs) will be used to create node tree fragment
classmethod bind(data_property, getter, setter)[source]

Creates an arbitrary named property in the class with given getter and setter. Not usually used directly.

Parameters:
  • data_property – property name
  • getterlambda: object, property getter
  • setterlambda value: None, property setter
classmethod bind_attribute(node_attribute, data_property, default=None, path=<function <lambda> at 0x26490c8>, getter=<function <lambda> at 0x2649140>, setter=<function <lambda> at 0x26491b8>)[source]

Binds the value of node object’s attribute to a property

Parameters:
  • node_attributeNode‘s attribute name
  • data_property – property name to be created
  • default – default value of the property (is PropertyNode doesn’t exist)
  • pathlambda self.node: PropertyNode, can be used to point binding to another Node instead of self.node.
  • getterlambda object: object, used to transform value when getting
  • setterlambda object: object, used to transform value when setting
classmethod bind_child(data_property, path=<function <lambda> at 0x2649578>, item_class=None)[source]

Directly binds a child Node to a BoundData property

Parameters:
  • data_property – property name to be created
  • pathlambda self.node: PropertyNode, can be used to point binding to another Node instead of self.node.
  • item_class – a BoundData subclass to be used for the property value
classmethod bind_collection(data_property, path=<function <lambda> at 0x26492a8>, selector=<function <lambda> at 0x2649320>, item_class=None, collection_class=<class 'reconfigure.items.bound.BoundCollection'>, **kwargs)[source]

Binds the subset of node’s children to a collection property

Parameters:
  • data_property – property name to be created
  • pathlambda self.node: PropertyNode, can be used to point binding to another Node instead of self.node.
  • selectorlambda Node: bool, can be used to filter out a subset of child nodes
  • item_class – a BoundData subclass to be used for collection items
  • collection_class – a BoundCollection subclass to be used for collection property itself
classmethod bind_name(data_property, getter=<function <lambda> at 0x2649410>, setter=<function <lambda> at 0x2649488>)[source]

Binds the value of node’s name attribute to a property

Parameters:
  • data_property – property name to be created
  • getterlambda object: object, used to transform value when getting
  • setterlambda object: object, used to transform value when setting
classmethod bind_property(node_property, data_property, default=None, default_remove=[], path=<function <lambda> at 0x2647e60>, getter=<function <lambda> at 0x2647ed8>, setter=<function <lambda> at 0x2647f50>)[source]

Binds the value of a child reconfigure.node.PropertyNode to a property

Parameters:
  • node_propertyPropertyNode‘s name
  • data_property – property name to be created
  • default – default value of the property (is PropertyNode doesn’t exist)
  • default_remove – if setting a value contained in default_remove, the target property is removed
  • pathlambda self.node: PropertyNode, can be used to point binding to another Node instead of self.node.
  • getterlambda object: object, used to transform value when getting
  • setterlambda object: object, used to transform value when setting
template(**kwargs)[source]

Override to create empty objects.

Returns:a reconfigure.nodes.Node tree that will be used as a template for new BoundData instance
to_dict()[source]
to_json()[source]
class reconfigure.items.bound.BoundDictionary(key=None, **kwargs)[source]

Binds a dict-like object to a set of nodes. Accepts same params as BoundCollection plus key

Parameters:keylambda value: object, is used to get key for value in the collection
iteritems()[source]
pop(key)[source]
rebuild()[source]
rebuild_dict()[source]
setdefault(k, v)[source]
to_dict()[source]
update(other)[source]
values()[source]

Previous topic

reconfigure.builders

This Page