def _create_nested_namespaces(path): assert not path.startswith(Node.PATH_SEPARATOR) splitpath = Node.splitpath(path) root = nodes.Namespace(name=splitpath[0]) node = root for name in splitpath[1:]: new_node = nodes.Namespace(name=name) node.insert(new_node) node = new_node return root, node
def create(properties): destination = properties.destination field = Node.jointwo(properties.source_type, properties.source_field) result = ExplicitReference(name="er_{field}_{destination}".format( field=field.replace(Node.PATH_SEPARATOR, '_'), destination=destination.replace(Node.PATH_SEPARATOR, '_')), properties=properties) result.insert(ResourceReference(name=destination)) result.insert(FieldReference(name=field)) result.insert(StructureReference(name=properties.source_type)) return result
def create_tree_with_topological_ordering(): return SyntaxTree( Node("ns").insert( Node("S0"), Node("A0").insert( Node("R0").insert(refs.TypeReference("ns.A1")), Node("R1").insert(refs.TypeReference("ns.S0"))), Node("A1")))
def create_tree_with_cycle(): return SyntaxTree( Node("a").insert( Node("b").insert(Structure("c").insert(refs.TypeReference("a.d"))), Node("d").insert(refs.TypeReference("a.b"))))
def create_tree_with_type_refs(): return SyntaxTree( Node("a").insert( Node("b").insert(Node("d"), refs.TypeReference("a.c.e")), Node("c").insert(Node("e"), refs.TypeReference("a.b.d"))))
def create_basic_tree(): return SyntaxTree( Node("a").insert( Node("b").insert(Node("c"), Node("d"), Node("e")), Node("f").insert(Node("g").insert(Node("h")))))