示例#1
0
    def attributes(self):
        generator = NamePrefixGenerator(prefix='_attr_')
        result = []
        if self._extension and hasattr(self._extension, 'attributes'):
            result.extend(self._extension.attributes)

        if self._restriction and hasattr(self._restriction, 'attributes'):
            pass

        elm_names = {name for name, elm in self.elements if name is not None}
        attributes = []
        for attr in self._attributes:
            if isinstance(attr, AttributeGroup):
                attributes.extend(attr.attributes)
            else:
                attributes.append(attr)

        for attr in attributes:
            if attr.name is None:
                name = generator.get_name()
            elif attr.name in elm_names:
                name = 'attr__%s' % attr.name
            else:
                name = attr.name
            result.append((name, attr))
        return result
示例#2
0
 def attributes(self):
     generator = NamePrefixGenerator(prefix='_attr_')
     result = []
     elm_names = {name for name, elm in self.elements if name is not None}
     for attr in self._attributes_unwrapped:
         if attr.name is None:
             name = generator.get_name()
         elif attr.name in elm_names:
             name = 'attr__%s' % attr.name
         else:
             name = attr.name
         result.append((name, attr))
     return result
示例#3
0
 def attributes(self):
     generator = NamePrefixGenerator(prefix="_attr_")
     result = []
     elm_names = {name for name, elm in self.elements if name is not None}
     for attr in self._attributes_unwrapped:
         if attr.name is None:
             name = generator.get_name()
         elif attr.name in elm_names:
             name = "attr__%s" % attr.name
         else:
             name = attr.name
         result.append((name, attr))
     return result
示例#4
0
    def elements_nested(self):
        """List of tuples containing the element name and the element"""
        result = []
        generator = NamePrefixGenerator()

        if self._extension:
            name = generator.get_name()
            if not hasattr(self._extension, 'elements_nested'):
                result.append((name, Element(name, self._extension)))
            else:
                result.extend(self._extension.elements_nested)
        # _element is one of All, Choice, Group, Sequence
        if self._element:
            result.append((generator.get_name(), self._element))
        return result
示例#5
0
    def attributes(self):
        generator = NamePrefixGenerator(prefix='_attr_')
        result = []
        if self._extension and hasattr(self._extension, 'attributes'):
            result.extend(self._extension.attributes)

        elm_names = {name for name, elm in self.elements if name is not None}
        attrs = []
        for attr in self._attributes:
            if attr.name is None:
                name = generator.get_name()
            elif attr.name in elm_names:
                name = 'attr__%s' % attr.name
            else:
                name = attr.name
            attrs.append((name, attr))
        result.extend(attrs)
        return result
示例#6
0
    def elements_nested(self):
        """List of tuples containing the element name and the element"""
        result = []
        generator = NamePrefixGenerator()

        # Handle wsdl:arrayType objects
        attrs = {attr.qname.text: attr for attr in self._attributes if attr.qname}
        array_type = attrs.get("{http://schemas.xmlsoap.org/soap/encoding/}arrayType")
        if array_type:
            name = generator.get_name()
            if isinstance(self._element, Group):
                return [(name, Sequence([Any(max_occurs="unbounded", restrict=array_type.array_type)]))]
            else:
                return [(name, self._element)]

        # _element is one of All, Choice, Group, Sequence
        if self._element:
            result.append((generator.get_name(), self._element))
        return result
示例#7
0
    def elements_nested(self):
        """List of tuples containing the element name and the element"""
        result = []
        generator = NamePrefixGenerator()

        # Handle wsdl:arrayType objects
        if self._array_type:
            name = generator.get_name()
            if isinstance(self._element, Group):
                result = [(name, Sequence([
                    Any(max_occurs='unbounded', restrict=self._array_type.array_type)
                ]))]
            else:
                result = [(name, self._element)]
        else:
            # _element is one of All, Choice, Group, Sequence
            if self._element:
                result.append((generator.get_name(), self._element))
        return result
示例#8
0
文件: complex.py 项目: Eveler/dmsic
    def elements_nested(self):
        """List of tuples containing the element name and the element"""
        result = []
        generator = NamePrefixGenerator()

        # Handle wsdl:arrayType objects
        if self._array_type:
            name = generator.get_name()
            if isinstance(self._element, Group):
                result = [(name, Sequence([
                    Any(max_occurs='unbounded', restrict=self._array_type.array_type)
                ]))]
            else:
                result = [(name, self._element)]
        else:
            # _element is one of All, Choice, Group, Sequence
            if self._element:
                result.append((generator.get_name(), self._element))
        return result
示例#9
0
    def elements_nested(self):
        """List of tuples containing the element name and the element"""
        result = []
        generator = NamePrefixGenerator()
        generator_2 = UniqueNameGenerator()

        for elm in self:
            if isinstance(elm, (All, Choice, Group, Sequence)):
                if elm.accepts_multiple:
                    result.append((generator.get_name(), elm))
                else:
                    for sub_name, sub_elm in elm.elements:
                        sub_name = generator_2.create_name(sub_name)
                    result.append((None, elm))
            elif isinstance(elm, (Any, Choice)):
                result.append((generator.get_name(), elm))
            else:
                name = generator_2.create_name(elm.name)
                result.append((name, elm))
        return result
示例#10
0
    def elements_nested(self):
        """List of tuples containing the element name and the element"""
        result = []
        generator = NamePrefixGenerator()
        generator_2 = UniqueNameGenerator()

        for elm in self:
            if isinstance(elm, (All, Choice, Group, Sequence)):
                if elm.accepts_multiple:
                    result.append((generator.get_name(), elm))
                else:
                    for sub_name, sub_elm in elm.elements:
                        sub_name = generator_2.create_name(sub_name)
                    result.append((None, elm))
            elif isinstance(elm, (Any, Choice)):
                result.append((generator.get_name(), elm))
            else:
                name = generator_2.create_name(elm.name)
                result.append((name, elm))
        return result
示例#11
0
    def attributes(self):
        generator = NamePrefixGenerator(prefix='_attr_')
        result = []
        if self._extension and hasattr(self._extension, 'attributes'):
            result.extend(self._extension.attributes)
        if self._restriction and hasattr(self._restriction, 'attributes'):
            result.extend(self._restriction.attributes)

        elm_names = {name for name, elm in self.elements if name is not None}
        attrs = []
        for attr in self._attributes:
            if attr.name is None:
                name = generator.get_name()
            elif attr.name in elm_names:
                name = 'attr__%s' % attr.name
            else:
                name = attr.name
            attrs.append((name, attr))
        result.extend(attrs)
        return result
示例#12
0
    def elements_nested(self):
        """List of tuples containing the element name and the element"""
        result = []
        generator = NamePrefixGenerator()

        # Handle wsdl:arrayType objects
        attrs = {attr.qname.text: attr for attr in self._attributes if attr.qname}
        array_type = attrs.get('{http://schemas.xmlsoap.org/soap/encoding/}arrayType')
        if array_type:
            name = generator.get_name()
            if isinstance(self._element, Group):
                return [(name, Sequence([
                    Any(max_occurs='unbounded', restrict=array_type.array_type)
                ]))]
            else:
                return [(name, self._element)]

        # _element is one of All, Choice, Group, Sequence
        if self._element:
            result.append((generator.get_name(), self._element))
        return result
示例#13
0
    def elements_nested(self):
        """List of tuples containing the element name and the element"""
        result = []
        generator = NamePrefixGenerator()

        if self._extension:
            name = generator.get_name()
            if not hasattr(self._extension, 'elements_nested'):
                result.append((name, Element(name, self._extension)))
            else:
                result.extend(self._extension.elements_nested)

        if self._restriction:
            name = generator.get_name()
            if not hasattr(self._restriction, 'elements_nested'):
                result.append((name, Element(name, self._restriction)))
            else:
                result.extend(self._restriction.elements_nested)

        # _element is one of All, Choice, Group, Sequence
        if self._element:
            result.append((generator.get_name(), self._element))
        return result
示例#14
0
    def elements_nested(self):
        """List of tuples containing the element name and the element"""
        result = []
        generator = NamePrefixGenerator()

        if self._extension:
            name = generator.get_name()
            if not hasattr(self._extension, 'elements_nested'):
                result.append((name, Element(name, self._extension)))
            else:
                result.extend(self._extension.elements_nested)

        if self._restriction and not self._element:
            # So this is a workaround to support wsdl:arrayType. This doesn't
            # actually belong here but for now it's the easiest way to achieve
            # this. What this does it that is checks if the restriction
            # contains an arrayType attribute and then use that to retrieve
            # the xsd type for the array. (We ignore AnyAttributes here)
            attrs = {attr.qname.text: attr for attr in self._attributes if attr.qname}
            array_type = attrs.get('{http://schemas.xmlsoap.org/soap/encoding/}arrayType')
            if array_type:
                name = generator.get_name()
                result.append((name, Sequence([
                    Any(max_occurs='unbounded', restrict=array_type.array_type)
                ])))
            else:
                name = generator.get_name()
                if not hasattr(self._restriction, 'elements_nested'):
                    result.append((name, Element(name, self._restriction)))
                else:
                    result.extend(self._restriction.elements_nested)

        # _element is one of All, Choice, Group, Sequence
        if self._element:
            result.append((generator.get_name(), self._element))
        return result
示例#15
0
    def elements_nested(self):
        """List of tuples containing the element name and the element"""
        result = []
        generator = NamePrefixGenerator()

        if self._extension:
            name = generator.get_name()
            if not hasattr(self._extension, 'elements_nested'):
                result.append((name, Element(name, self._extension)))
            else:
                result.extend(self._extension.elements_nested)

        if self._restriction and not self._element:
            # So this is a workaround to support wsdl:arrayType. This doesn't
            # actually belong here but for now it's the easiest way to achieve
            # this. What this does it that is checks if the restriction
            # contains an arrayType attribute and then use that to retrieve
            # the xsd type for the array. (We ignore AnyAttributes here)
            attrs = {
                attr.qname.text: attr
                for attr in self._attributes if attr.qname
            }
            array_type = attrs.get(
                '{http://schemas.xmlsoap.org/soap/encoding/}arrayType')
            if array_type:
                name = generator.get_name()
                result.append((name,
                               Sequence([
                                   Any(max_occurs='unbounded',
                                       restrict=array_type.array_type)
                               ])))
            else:
                name = generator.get_name()
                if not hasattr(self._restriction, 'elements_nested'):
                    result.append((name, Element(name, self._restriction)))
                else:
                    result.extend(self._restriction.elements_nested)

        # _element is one of All, Choice, Group, Sequence
        if self._element:
            result.append((generator.get_name(), self._element))
        return result