def clone_attribute(cls, attr: Attr, restrictions: Restrictions, prefix: Optional[str] = None) -> Attr: """ Clone the given attribute and merge its restrictions with the given instance. Prepend the given namespace prefix to the attribute name if available. """ clone = attr.clone() clone.restrictions.merge(restrictions) if prefix: for attr_type in clone.types: if not attr_type.native and attr_type.name.find(":") == -1: attr_type.name = f"{prefix}:{attr_type.name}" return clone
def clone_attribute(cls, attr: Attr, restrictions: Restrictions) -> Attr: """Clone the given attribute and merge its restrictions with the given instance.""" clone = attr.clone() clone.restrictions.merge(restrictions) return clone