def build_inner_classes(self, obj: ElementBase) -> Iterator[Class]: """Find and convert anonymous types to a class instances.""" if isinstance(obj, SimpleType) and obj.is_enumeration: yield self.build_class(obj) else: for child in obj.children(): if isinstance(child, ComplexType) or (isinstance(child, SimpleType) and child.is_enumeration): child.name = obj.real_name yield self.build_class(child) else: yield from self.build_inner_classes(child)
def element_children( cls, obj: ElementBase, restrictions: Restrictions ) -> Iterator[Tuple[ElementBase, Restrictions]]: """Recursively find and return all child elements that are qualified to be class attributes.""" for child in obj.children(): if child.is_attribute: yield child, restrictions else: yield from cls.element_children( child, restrictions=Restrictions.from_element(child) )
def element_children( self, obj: ElementBase, restrictions: Optional[Restrictions] = None ) -> Iterator[Tuple[AttributeElement, Restrictions]]: """Recursively find and return all child elements that are qualified to be class attributes.""" for child in obj.children(): if child.is_attribute: yield child, restrictions or Restrictions() else: yield from self.element_children( child, restrictions=Restrictions.from_element(child) )
def build_inner_classes( cls, obj: ElementBase, module: str, namespace: Optional[str] ) -> Iterator[Class]: """Find and convert anonymous types to a class instances.""" if isinstance(obj, SimpleType) and obj.is_enumeration: yield cls.build_class(obj, obj.class_name, module, namespace) else: for child in obj.children(): if isinstance(child, ComplexType) or ( isinstance(child, SimpleType) and child.is_enumeration ): child.name = obj.real_name yield cls.build_class(child, obj.class_name, module, namespace) else: yield from cls.build_inner_classes(child, module, namespace)
def children_extensions(self, obj: ElementBase, target: Class) -> Iterator[Extension]: """ Recursively find and return all target's Extension classes. If the initial given obj has a type attribute include it in result. """ for child in obj.children(): if child.is_attribute: continue for ext in child.extensions: yield self.build_class_extension(target, ext, child.index, child.get_restrictions()) yield from self.children_extensions(child, target)