Пример #1
0
    def build_data_type(
        cls, target: Class, name: str, index: int = 0, forward: bool = False
    ) -> AttrType:
        """Create an attribute type for the target class."""
        prefix, suffix = text.split(name)
        native = False
        namespace = target.ns_map.get(prefix)

        if Namespace.get_enum(namespace) and DataType.get_enum(suffix):
            name = suffix
            native = True

        return AttrType(name=name, index=index, native=native, forward=forward,)
Пример #2
0
    def build_data_type(
        cls, target: Class, name: str, index: int = 0, forward: bool = False
    ) -> AttrType:
        """Create an attribute type for the target class."""
        prefix, suffix = text.split(name)
        namespace = target.ns_map.get(prefix, target.qname.namespace)
        native = (
            Namespace.get_enum(namespace) is not None
            and DataType.get_enum(suffix) is not None
        )

        return AttrType(
            qname=QName(namespace, suffix), index=index, native=native, forward=forward,
        )
Пример #3
0
    def build_data_type(self,
                        target: Class,
                        name: str,
                        index: int = 0,
                        forward_ref: bool = False) -> AttrType:
        prefix, suffix = text.split(name)
        native = False
        namespace = target.ns_map.get(prefix)

        if Namespace.get_enum(namespace) and DataType.get_enum(suffix):
            name = suffix
            native = True

        return AttrType(
            name=name,
            index=index,
            native=native,
            forward_ref=forward_ref,
        )
Пример #4
0
 def native_type(self) -> Any:
     """Return the python build-in type if it's a native type."""
     data_type = DataType.get_enum(self.name) if self.native else None
     return data_type.local if data_type else None
Пример #5
0
 def native_code(self) -> Optional[str]:
     """Return the xml data type if it's native type."""
     data_type = DataType.get_enum(self.name) if self.native else None
     return data_type.code if data_type else None
Пример #6
0
 def native_name(self) -> Optional[str]:
     """Return the python build-in type name: `'str'`, `'int'` if it's
     native type."""
     data_type = DataType.get_enum(self.name) if self.native else None
     return data_type.local_name if data_type else None
Пример #7
0
 def native_type(self) -> Any:
     data_type = DataType.get_enum(self.name) if self.native else None
     return data_type.local if data_type else None
Пример #8
0
 def native_code(self) -> Optional[str]:
     data_type = DataType.get_enum(self.name) if self.native else None
     return data_type.code if data_type else None