Esempio n. 1
0
 def reset_attribute_type(cls, attr_type: AttrType, use_str: bool = True):
     """Reset the attribute type to string or any simple type."""
     attr_type.qname = str(
         DataType.STRING if use_str else DataType.ANY_SIMPLE_TYPE)
     attr_type.native = True
     attr_type.circular = False
     attr_type.forward = False
Esempio n. 2
0
    def copy_inner_class(cls, source: Class, target: Class, attr: Attr,
                         attr_type: AttrType):
        """
        Check if the given attr type is a forward reference and copy its inner
        class from the source to the target class.

        Checks:
            1. Update type if inner class in a circular reference
            2. Copy inner class, rename it if source is a simple type.
        """
        if not attr_type.forward:
            return

        # This will fail if no inner class is found, too strict???
        inner = ClassUtils.find_inner(source, attr_type.qname)

        if inner is target:
            attr_type.circular = True
        else:
            clone = inner.clone()
            clone.package = target.package
            clone.module = target.module

            # Simple type, update the name
            if clone.name == "@value":
                namespace, _ = split_qname(clone.qname)
                clone.qname = attr_type.qname = build_qname(
                    namespace, attr.name)

            target.inner.append(clone)
Esempio n. 3
0
 def set_circular_flag(self, source: Class, target: Class,
                       attr_type: AttrType):
     """Update circular reference flag."""
     attr_type.circular = self.is_circular_dependency(source, target, set())
Esempio n. 4
0
 def reset_attribute_type(cls, attr_type: AttrType):
     """Reset the attribute type to native string."""
     attr_type.name = DataType.STRING.code
     attr_type.native = True
     attr_type.circular = False
     attr_type.forward = False
Esempio n. 5
0
 def reset_attribute_type(cls, attr_type: AttrType):
     """Reset the attribute type to native string."""
     attr_type.qname = QName(Namespace.XS.uri, DataType.STRING.code)
     attr_type.native = True
     attr_type.circular = False
     attr_type.forward = False