def build_class_extensions(cls, obj: ElementBase, target: Class): """Build the item class extensions from the given ElementBase children.""" restrictions = obj.get_restrictions() extensions = [ cls.build_class_extension(target, base, restrictions) for base in obj.bases ] extensions.extend(cls.children_extensions(obj, target)) target.extensions = collections.unique_sequence(extensions)
def build_class_extensions(cls, obj: ElementBase, target: Class): """Build the item class extensions from the given ElementBase children.""" extensions = set() raw_type = obj.raw_type if raw_type: restrictions = obj.get_restrictions() extensions.add( cls.build_class_extension(target, raw_type, restrictions)) extensions.update(cls.children_extensions(obj, target)) target.extensions = list(extensions)
def build_class_extensions(cls, obj: ElementBase, target: Class): """Build the item class extensions from the given ElementBase children.""" extensions = {} raw_type = obj.raw_type if raw_type: restrictions = obj.get_restrictions() extension = cls.build_class_extension(target, raw_type, 0, restrictions) extensions[raw_type] = extension for extension in cls.children_extensions(obj, target): extensions[extension.type.name] = extension target.extensions = sorted(extensions.values(), key=lambda x: x.type.index)
def from_element(cls, element: ElementBase) -> "Restrictions": """Static constructor from an xsd model.""" return cls(**element.get_restrictions())
def from_element(cls, element: ElementBase) -> "Restrictions": return cls(**element.get_restrictions())