architxt.generator#
Generator of instances.
Functions
|
Generate a collection tree. |
|
Generate a group tree structure with the given name and elements. |
|
Generate a database instances as a tree based on the given groups and relations schema. |
|
Generate a relation tree structure based on the given parameters. |
- architxt.generator.gen_collection(name, elements)[source]#
Generate a collection tree.
- Parameters:
- Return type:
- Returns:
A tree representing the collection.
>>> from architxt.tree import Tree >>> elems = [Tree('Element1', []), Tree('Element2', [])] >>> collection_tree = gen_collection('Collection', elems) >>> print(collection_tree.pformat(margin=255)) (COLL::Collection (Element1 ) (Element2 ))
- architxt.generator.gen_group(schema, name)[source]#
Generate a group tree structure with the given name and elements.
- Parameters:
- Return type:
- Returns:
The generated group tree.
>>> schema = Schema.from_description(groups={'Fruits': {'Apple', 'Banana', 'Cherry'}}) >>> group_tree = gen_group(schema, NodeLabel(NodeType.GROUP, 'Fruits')) >>> print(group_tree.pformat(margin=255)) (GROUP::Fruits (ENT::Apple data) (ENT::Banana data) (ENT::Cherry data))
- architxt.generator.gen_instance(schema, *, size=200, generate_collections=True)[source]#
Generate a database instances as a tree based on the given groups and relations schema.
- Parameters:
- Return type:
- Returns:
A tree representing the generated instance.
- architxt.generator.gen_relation(schema, name)[source]#
Generate a relation tree structure based on the given parameters.
- Parameters:
- Return type:
- Returns:
The generated relation tree.
>>> schema = Schema.from_description( ... groups={'Fruits': {'Apple', 'Banana'}, 'Colors': {'Red', 'Blue'}}, ... rels={'Preference': ('Fruits', 'Colors')} ... ) >>> relation_tree = gen_relation(schema, NodeLabel(NodeType.REL, 'Preference')) >>> print(relation_tree.pformat(margin=255)) (REL::Preference (GROUP::Colors (ENT::Blue data) (ENT::Red data)) (GROUP::Fruits (ENT::Apple data) (ENT::Banana data)))