Exemple #1
0
 def __str__(self):
     import pyxb.binding.basis
     import xml.dom
     value = ''
     boundto = ''
     location = ''
     if isinstance(self.element, pyxb.binding.basis._TypeBinding_mixin):
         eb = self.element._element()
         boundto = ''
         if eb is not None:
             boundto = ' bound to %s' % (eb.name(), )
         if isinstance(self.element,
                       pyxb.binding.basis.simpleTypeDefinition):
             value = self.element.xsdLiteral()
         elif self.element._IsSimpleTypeContent():
             value = six.text_type(self.element.value())
         else:
             value = 'Complex value'
     elif isinstance(self.element, xml.dom.Node):
         value = 'DOM node %s' % (self.element.nodeName, )
     else:
         value = '%s type %s' % (six.text_type(
             self.element), type(self.element))
     if self.location is not None:
         location = ' at %s' % (self.location, )
     return six.u('%s%s not permitted%s') % (value, boundto, location)
Exemple #2
0
 def __str__ (self):
     rv = [ six.u('NamespaceContext ') ]
     if self.defaultNamespace() is not None:
         rv.extend([ '(defaultNamespace=', six.text_type(self.defaultNamespace()), ') '])
     if self.targetNamespace() is not None:
         rv.extend([ '(targetNamespace=', six.text_type(self.targetNamespace()), ') '])
     rv.append("\n")
     for (pfx, ns) in six.iteritems(self.inScopeNamespaces()):
         if pfx is not None:
             rv.append('  xmlns:%s=%s' % (pfx, six.text_type(ns)))
     return six.u('').join(rv)
Exemple #3
0
 def read_archive(self, archive, keep_comments=False):
     res = {}
     for filename in archive.namelist():
         mf_file = archive.open(filename)
         try:
             if (keep_comments):
                 res[six.text_type(filename)] = mf_file.readlines()
             else:
                 res[six.text_type(filename)] = \
                         [line for line in mf_file.readlines()
                                 if not line.startswith(b'#')]
         finally:
             mf_file.close()
     return res
Exemple #4
0
 def _valueDescription (self):
     import xml.dom
     if isinstance(self.value, pyxb.binding.basis._TypeBinding_mixin):
         return self.value._diagnosticName()
     if isinstance(self.value, xml.dom.Node):
         return self.value.nodeName
     return six.text_type(self.value)
Exemple #5
0
 def _valueDescription(self):
     import xml.dom
     if isinstance(self.value, pyxb.binding.basis._TypeBinding_mixin):
         return self.value._diagnosticName()
     if isinstance(self.value, xml.dom.Node):
         return self.value.nodeName
     return six.text_type(self.value)
Exemple #6
0
def _InitializeAllEsc():
    """Set the values in _AllEsc without introducing C{k} and C{v} into
    the module."""

    _AllEsc.update({six.u('.'): pyxb.utils.unicode.WildcardEsc})
    bs = six.unichr(0x5c)
    for k, v in six.iteritems(pyxb.utils.unicode.SingleCharEsc):
        _AllEsc[bs + six.text_type(k)] = v
    for k, v in six.iteritems(pyxb.utils.unicode.MultiCharEsc):
        _AllEsc[bs + six.text_type(k)] = v
    for k, v in six.iteritems(pyxb.utils.unicode.catEsc):
        _AllEsc[bs + six.text_type(k)] = v
    for k, v in six.iteritems(pyxb.utils.unicode.complEsc):
        _AllEsc[bs + six.text_type(k)] = v
    for k, v in six.iteritems(pyxb.utils.unicode.IsBlockEsc):
        _AllEsc[bs + six.text_type(k)] = v
Exemple #7
0
def _InitializeAllEsc ():
    """Set the values in _AllEsc without introducing C{k} and C{v} into
    the module."""

    _AllEsc.update({ six.u('.'): pyxb.utils.unicode.WildcardEsc })
    bs = six.unichr(0x5c)
    for k, v in six.iteritems(pyxb.utils.unicode.SingleCharEsc):
        _AllEsc[bs + six.text_type(k)] = v
    for k, v in six.iteritems(pyxb.utils.unicode.MultiCharEsc):
        _AllEsc[bs + six.text_type(k)] = v
    for k, v in six.iteritems(pyxb.utils.unicode.catEsc):
        _AllEsc[bs + six.text_type(k)] = v
    for k, v in six.iteritems(pyxb.utils.unicode.complEsc):
        _AllEsc[bs + six.text_type(k)] = v
    for k, v in six.iteritems(pyxb.utils.unicode.IsBlockEsc):
        _AllEsc[bs + six.text_type(k)] = v
 def __str__(self):
     rv = [six.u('NamespaceContext ')]
     if self.defaultNamespace() is not None:
         rv.extend([
             '(defaultNamespace=',
             six.text_type(self.defaultNamespace()), ') '
         ])
     if self.targetNamespace() is not None:
         rv.extend([
             '(targetNamespace=',
             six.text_type(self.targetNamespace()), ') '
         ])
     rv.append("\n")
     for (pfx, ns) in six.iteritems(self.inScopeNamespaces()):
         if pfx is not None:
             rv.append('  xmlns:%s=%s' % (pfx, six.text_type(ns)))
     return six.u('').join(rv)
Exemple #9
0
    def details (self):
        """Provide information describing why validation failed.

        In many cases, this is simply the informal string content that
        would be obtained through the C{str} built-in function.  For
        certain errors this method gives more details on what would be
        acceptable and where the descriptions can be found in the
        original schema.

        @return: a string description of validation failure"""
        return six.text_type(self)
Exemple #10
0
 def details(self):
     import pyxb.binding.basis
     import pyxb.binding.content
     i = self.instance
     rv = []
     if i._element() is not None:
         rv.append('The containing element %s is defined at %s.' %
                   (i._element().name(), i._element().xsdLocation()))
     rv.append(
         'The containing element type %s is defined at %s' %
         (self.instance._Name(), six.text_type(self.instance._XSDLocation)))
     rv.append('The %s automaton %s in an accepting state.' %
               (self.instance._Name(),
                self.fac_configuration.isAccepting() and "is" or "is not"))
     if self.symbols is None:
         rv.append('Any accepted content has been stored in instance')
     elif 0 == len(self.symbols):
         rv.append('No content has been accepted')
     else:
         rv.append('The last accepted content was %s' %
                   (self.symbols[-1].value._diagnosticName(), ))
     if isinstance(self.instance, pyxb.binding.basis.complexTypeDefinition
                   ) and self.instance._IsMixed():
         rv.append('Character information content would be permitted.')
     acceptable = self.fac_configuration.acceptableSymbols()
     if 0 == len(acceptable):
         rv.append(
             'No elements or wildcards would be accepted at this point.')
     else:
         rv.append(
             'The following element and wildcard content would be accepted:'
         )
         rv2 = []
         for u in acceptable:
             if isinstance(u, pyxb.binding.content.ElementUse):
                 rv2.append('An element %s per %s' %
                            (u.elementBinding().name(), u.xsdLocation()))
             else:
                 assert isinstance(u, pyxb.binding.content.WildcardUse)
                 rv2.append('A wildcard per %s' % (u.xsdLocation(), ))
         rv.append('\t' + '\n\t'.join(rv2))
     if (self.symbol_set is None) or (0 == len(self.symbol_set)):
         rv.append('No content remains unconsumed')
     else:
         rv.append(
             'The following content was not processed by the automaton:')
         rv2 = []
         for (ed, syms) in six.iteritems(self.symbol_set):
             if ed is None:
                 rv2.append('xs:any (%u instances)' % (len(syms), ))
             else:
                 rv2.append('%s (%u instances)' % (ed.name(), len(syms)))
         rv.append('\t' + '\n\t'.join(rv2))
     return '\n'.join(rv)
Exemple #11
0
    def details(self):
        """Provide information describing why validation failed.

        In many cases, this is simply the informal string content that
        would be obtained through the C{str} built-in function.  For
        certain errors this method gives more details on what would be
        acceptable and where the descriptions can be found in the
        original schema.

        @return: a string description of validation failure"""
        return six.text_type(self)
Exemple #12
0
def _DefaultXMLIdentifierToPython (identifier):
    """Default implementation for _XMLIdentifierToPython

    For historical reasons, this converts the identifier from a str to
    unicode in the system default encoding.  This should have no
    practical effect.

    @param identifier : some XML identifier

    @return: C{unicode(identifier)}
    """

    return six.text_type(identifier)
Exemple #13
0
def _DefaultXMLIdentifierToPython (identifier):
    """Default implementation for _XMLIdentifierToPython

    For historical reasons, this converts the identifier from a str to
    unicode in the system default encoding.  This should have no
    practical effect.

    @param identifier : some XML identifier

    @return: C{unicode(identifier)}
    """

    return six.text_type(identifier)
Exemple #14
0
 def __str__ (self):
     import pyxb.binding.basis
     import xml.dom
     value = ''
     boundto = ''
     location = ''
     if isinstance(self.element, pyxb.binding.basis._TypeBinding_mixin):
         eb = self.element._element()
         boundto = ''
         if eb is not None:
             boundto = ' bound to %s' % (eb.name(),)
         if isinstance(self.element, pyxb.binding.basis.simpleTypeDefinition):
             value = self.element.xsdLiteral()
         elif self.element._IsSimpleTypeContent():
             value = six.text_type(self.element.value())
         else:
             value = 'Complex value'
     elif isinstance(self.element, xml.dom.Node):
         value = 'DOM node %s' % (self.element.nodeName,)
     else:
         value = '%s type %s' % (six.text_type(self.element), type(self.element))
     if self.location is not None:
         location = ' at %s' % (self.location,)
     return six.u('%s%s not permitted%s') % (value, boundto, location)
    def valueAsText (self, value, enable_default_namespace=True):
        """Represent a simple type value as XML text.

        This is essentially what C{value.xsdLiteral()} does, but this one
        handles any special cases such as QName values where the lexical
        representation cannot be done in isolation of external information
        such as namespace declarations."""
        from pyxb.binding.basis import simpleTypeDefinition, STD_list
        if isinstance(value, pyxb.namespace.ExpandedName):
            return self.qnameAsText(value, enable_default_namespace=enable_default_namespace)
        if isinstance(value, STD_list):
            return ' '.join([ self.valueAsText(_v, enable_default_namespace=enable_default_namespace) for _v in value ])
        if isinstance(value, simpleTypeDefinition):
            return value.xsdLiteral()
        assert value is not None
        return six.text_type(value)
Exemple #16
0
    def valueAsText (self, value, enable_default_namespace=True):
        """Represent a simple type value as XML text.

        This is essentially what C{value.xsdLiteral()} does, but this one
        handles any special cases such as QName values where the lexical
        representation cannot be done in isolation of external information
        such as namespace declarations."""
        from pyxb.binding.basis import simpleTypeDefinition, STD_list
        if isinstance(value, pyxb.namespace.ExpandedName):
            return self.qnameAsText(value, enable_default_namespace=enable_default_namespace)
        if isinstance(value, STD_list):
            return ' '.join([ self.valueAsText(_v, enable_default_namespace=enable_default_namespace) for _v in value ])
        if isinstance(value, simpleTypeDefinition):
            return value.xsdLiteral()
        assert value is not None
        return six.text_type(value)
Exemple #17
0
 def details(self):
     import pyxb.binding.basis
     import pyxb.binding.content
     i = self.instance
     rv = []
     if i._element() is not None:
         rv.append('The containing element %s is defined at %s.' %
                   (i._element().name(), i._element().xsdLocation()))
     rv.append(
         'The containing element type %s is defined at %s' %
         (self.instance._Name(), six.text_type(self.instance._XSDLocation)))
     if self.location is not None:
         rv.append('The unrecognized content %s begins at %s' %
                   (self._valueDescription(), self.location))
     else:
         rv.append('The unrecognized content is %s' %
                   (self._valueDescription(), ))
     rv.append(
         'The %s automaton %s in an accepting state.' %
         (self.instance._Name(),
          self.automaton_configuration.isAccepting() and "is" or "is not"))
     if isinstance(self.instance, pyxb.binding.basis.complexTypeDefinition
                   ) and self.instance._IsMixed():
         rv.append('Character information content would be permitted.')
     acceptable = self.automaton_configuration.acceptableContent()
     if 0 == len(acceptable):
         rv.append(
             'No elements or wildcards would be accepted at this point.')
     else:
         rv.append(
             'The following element and wildcard content would be accepted:'
         )
         rv2 = []
         for u in acceptable:
             if isinstance(u, pyxb.binding.content.ElementUse):
                 rv2.append('An element %s per %s' %
                            (u.elementBinding().name(), u.xsdLocation()))
             else:
                 assert isinstance(u, pyxb.binding.content.WildcardUse)
                 rv2.append('A wildcard per %s' % (u.xsdLocation(), ))
         rv.append('\t' + '\n\t'.join(rv2))
     return '\n'.join(rv)
Exemple #18
0
    def __init__ (self, *args, **kw):
        """Raised when processing document and the content model is not satisfied.

        @keyword content : The value that could not be reconciled with the content model
        @keyword container : Optional binding instance into which the content was to be assigned
        @keyword element_use : Optional reference to an element use identifying the element to which the value was to be reconciled
        """
        self.__content = kw.pop('content', None)
        if args:
            self.__content = args[0]
        self.__container = kw.pop('container', None)
        self.__elementUse = kw.pop('element_use', None)
        if self.__content is not None:
            if self.__container is not None:
                kw.setdefault('message', '%s cannot accept wildcard content %s' % (self.__container._Name(), self.__content))
            elif self.__elementUse is not None:
                kw.setdefault('message', '%s not consistent with content model for %s' % (self.__content, self.__elementUse))
            else:
                kw.setdefault('message', six.text_type(self.__content))
        BadDocumentError.__init__(self, **kw)
Exemple #19
0
 def __str__ (self):
     value = self._valueDescription()
     acceptable = self.automaton_configuration.acceptableContent()
     if 0 == acceptable:
         expect = 'no more content'
     else:
         import pyxb.binding.content
         seen = set()
         names = []
         for u in acceptable:
             if isinstance(u, pyxb.binding.content.ElementUse):
                 n = six.text_type(u.elementBinding().name())
             else:
                 assert isinstance(u, pyxb.binding.content.WildcardUse)
                 n = 'xs:any'
             if not (n in seen):
                 names.append(n)
                 seen.add(n)
         expect = ' or '.join(names)
     location = ''
     if self.location is not None:
         location = ' at %s' % (self.location,)
     return six.u('Invalid content %s%s (expect %s)') % (value, location, expect)
Exemple #20
0
    def __init__(self, *args, **kw):
        """Raised when processing document and the content model is not satisfied.

        @keyword content : The value that could not be reconciled with the content model
        @keyword container : Optional binding instance into which the content was to be assigned
        @keyword element_use : Optional reference to an element use identifying the element to which the value was to be reconciled
        """
        self.__content = kw.pop('content', None)
        if args:
            self.__content = args[0]
        self.__container = kw.pop('container', None)
        self.__elementUse = kw.pop('element_use', None)
        if self.__content is not None:
            if self.__container is not None:
                kw.setdefault(
                    'message', '%s cannot accept wildcard content %s' %
                    (self.__container._Name(), self.__content))
            elif self.__elementUse is not None:
                kw.setdefault(
                    'message', '%s not consistent with content model for %s' %
                    (self.__content, self.__elementUse))
            else:
                kw.setdefault('message', six.text_type(self.__content))
        BadDocumentError.__init__(self, **kw)
Exemple #21
0
 def __str__(self):
     value = self._valueDescription()
     acceptable = self.automaton_configuration.acceptableContent()
     if 0 == acceptable:
         expect = 'no more content'
     else:
         import pyxb.binding.content
         seen = set()
         names = []
         for u in acceptable:
             if isinstance(u, pyxb.binding.content.ElementUse):
                 n = six.text_type(u.elementBinding().name())
             else:
                 assert isinstance(u, pyxb.binding.content.WildcardUse)
                 n = 'xs:any'
             if not (n in seen):
                 names.append(n)
                 seen.add(n)
         expect = ' or '.join(names)
     location = ''
     if self.location is not None:
         location = ' at %s' % (self.location, )
     return six.u('Invalid content %s%s (expect %s)') % (value, location,
                                                         expect)
Exemple #22
0
def ResolveSiblingNamespaces (sibling_namespaces):
    """Resolve all components in the sibling_namespaces.

    @param sibling_namespaces : A set of namespaces expected to be closed
    under dependency."""

    for ns in sibling_namespaces:
        ns.configureCategories([archive.NamespaceArchive._AnonymousCategory()])
        ns.validateComponentModel()

    def __keyForCompare (dependency_map):
        """Sort namespaces so dependencies get resolved first.

        Uses the trick underlying functools.cmp_to_key(), but optimized for
        this special case.  The dependency map is incorporated into the class
        definition by scope.
        """
        class K (object):
            def __init__ (self, ns, *args):
                self.__ns = ns

            # self compares less than other if self.ns is in the dependency set
            # of other.ns but not vice-versa.
            def __lt__ (self, other):
                return ((self.__ns in dependency_map.get(other.__ns, set())) \
                            and not (other.__ns in dependency_map.get(self.__ns, set())))

            # self compares equal to other if their namespaces are either
            # mutually dependent or independent.
            def __eq__ (self, other):
                return (self.__ns in dependency_map.get(other.__ns, set())) == (other.__ns in dependency_map.get(self.__ns, set()))

            # All other order metrics are derived.
            def __ne__ (self, other):
                return not self.__eq__(other)
            def __le__ (self, other):
                return self.__lt__(other) or self.__eq__(other)
            def __gt__ (self, other):
                return other.__lt__(self.__ns)
            def __ge__ (self, other):
                return other.__lt__(self.__ns) or self.__eq__(other)
        return K

    need_resolved_set = set(sibling_namespaces)
    dependency_map = {}
    last_state = None
    while need_resolved_set:
        need_resolved_list = list(need_resolved_set)
        if dependency_map:
            need_resolved_list.sort(key=__keyForCompare(dependency_map))
        need_resolved_set = set()
        dependency_map = {}
        for ns in need_resolved_list:
            if not ns.needsResolution():
                continue
            if not ns.resolveDefinitions(allow_unresolved=True):
                deps = dependency_map.setdefault(ns, set())
                for (c, dcs) in six.iteritems(ns._unresolvedDependents()):
                    for dc in dcs:
                        dns = dc.expandedName().namespace()
                        if dns != ns:
                            deps.add(dns)
                _log.info('Holding incomplete resolution %s depending on: ', ns.uri(), six.u(' ; ').join([ six.text_type(_dns) for _dns in deps ]))
                need_resolved_set.add(ns)
        # Exception termination check: if we have the same set of incompletely
        # resolved namespaces, and each has the same number of unresolved
        # components, assume there's an truly unresolvable dependency: either
        # due to circularity, or because there was an external namespace that
        # was missed from the sibling list.
        state = []
        for ns in need_resolved_set:
            state.append( (ns, len(ns._unresolvedComponents())) )
        state = tuple(state)
        if last_state == state:
            raise pyxb.LogicError('Unexpected external dependency in sibling namespaces: %s' % (six.u('\n  ').join( [six.text_type(_ns) for _ns in need_resolved_set ]),))
        last_state = state
Exemple #23
0
 def XsdLiteral (cls, value):
     return six.text_type(value)
Exemple #24
0
 def testPreserveString(self):
     cases = ["test", "  test", "  test", "\ttest", "\ttest\n\rtoo\n"]
     for c in cases:
         self.assertEqual(c, datatypes.string(c))
         self.assertEqual(c, datatypes.string(six.text_type(c)))
Exemple #25
0
 def XsdLiteral(cls, value):
     return six.text_type(value)
Exemple #26
0
 def testPreserveString (self):
     cases = [ "test", "  test", "  test", "\ttest", "\ttest\n\rtoo\n" ]
     for c in cases:
         self.assertEqual(c, datatypes.string(c))
         self.assertEqual(c, datatypes.string(six.text_type(c)))
Exemple #27
0
 def details (self):
     import pyxb.binding.basis
     import pyxb.binding.content
     i = self.instance
     rv = [ ]
     if i._element() is not None:
         rv.append('The containing element %s is defined at %s.' % (i._element().name(), i._element().xsdLocation()))
     rv.append('The containing element type %s is defined at %s' % (self.instance._Name(), six.text_type(self.instance._XSDLocation)))
     rv.append('The %s automaton %s in an accepting state.' % (self.instance._Name(), self.fac_configuration.isAccepting() and "is" or "is not"))
     if self.symbols is None:
         rv.append('Any accepted content has been stored in instance')
     elif 0 == len(self.symbols):
         rv.append('No content has been accepted')
     else:
         rv.append('The last accepted content was %s' % (self.symbols[-1].value._diagnosticName(),))
     if isinstance(self.instance, pyxb.binding.basis.complexTypeDefinition) and self.instance._IsMixed():
         rv.append('Character information content would be permitted.')
     acceptable = self.fac_configuration.acceptableSymbols()
     if 0 == len(acceptable):
         rv.append('No elements or wildcards would be accepted at this point.')
     else:
         rv.append('The following element and wildcard content would be accepted:')
         rv2 = []
         for u in acceptable:
             if isinstance(u, pyxb.binding.content.ElementUse):
                 rv2.append('An element %s per %s' % (u.elementBinding().name(), u.xsdLocation()))
             else:
                 assert isinstance(u, pyxb.binding.content.WildcardUse)
                 rv2.append('A wildcard per %s' % (u.xsdLocation(),))
         rv.append('\t' + '\n\t'.join(rv2))
     if (self.symbol_set is None) or (0 == len(self.symbol_set)):
         rv.append('No content remains unconsumed')
     else:
         rv.append('The following content was not processed by the automaton:')
         rv2 = []
         for (ed, syms) in six.iteritems(self.symbol_set):
             if ed is None:
                 rv2.append('xs:any (%u instances)' % (len(syms),))
             else:
                 rv2.append('%s (%u instances)' % (ed.name(), len(syms)))
         rv.append('\t' + '\n\t'.join(rv2))
     return '\n'.join(rv)
Exemple #28
0
 def details (self):
     import pyxb.binding.basis
     import pyxb.binding.content
     i = self.instance
     rv = [ ]
     if i._element() is not None:
         rv.append('The containing element %s is defined at %s.' % (i._element().name(), i._element().xsdLocation()))
     rv.append('The containing element type %s is defined at %s' % (self.instance._Name(), six.text_type(self.instance._XSDLocation)))
     if self.location is not None:
         rv.append('The unrecognized content %s begins at %s' % (self._valueDescription(), self.location))
     else:
         rv.append('The unrecognized content is %s' % (self._valueDescription(),))
     rv.append('The %s automaton %s in an accepting state.' % (self.instance._Name(), self.automaton_configuration.isAccepting() and "is" or "is not"))
     if isinstance(self.instance, pyxb.binding.basis.complexTypeDefinition) and self.instance._IsMixed():
         rv.append('Character information content would be permitted.')
     acceptable = self.automaton_configuration.acceptableContent()
     if 0 == len(acceptable):
         rv.append('No elements or wildcards would be accepted at this point.')
     else:
         rv.append('The following element and wildcard content would be accepted:')
         rv2 = []
         for u in acceptable:
             if isinstance(u, pyxb.binding.content.ElementUse):
                 rv2.append('An element %s per %s' % (u.elementBinding().name(), u.xsdLocation()))
             else:
                 assert isinstance(u, pyxb.binding.content.WildcardUse)
                 rv2.append('A wildcard per %s' % (u.xsdLocation(),))
         rv.append('\t' + '\n\t'.join(rv2))
     return '\n'.join(rv)
Exemple #29
0
def ResolveSiblingNamespaces(sibling_namespaces):
    """Resolve all components in the sibling_namespaces.

    @param sibling_namespaces : A set of namespaces expected to be closed
    under dependency."""

    for ns in sibling_namespaces:
        ns.configureCategories([archive.NamespaceArchive._AnonymousCategory()])
        ns.validateComponentModel()

    def __keyForCompare(dependency_map):
        """Sort namespaces so dependencies get resolved first.

        Uses the trick underlying functools.cmp_to_key(), but optimized for
        this special case.  The dependency map is incorporated into the class
        definition by scope.
        """
        class K(object):
            def __init__(self, ns, *args):
                self.__ns = ns

            # self compares less than other if self.ns is in the dependency set
            # of other.ns but not vice-versa.
            def __lt__(self, other):
                return ((self.__ns in dependency_map.get(other.__ns, set())) \
                            and not (other.__ns in dependency_map.get(self.__ns, set())))

            # self compares equal to other if their namespaces are either
            # mutually dependent or independent.
            def __eq__(self, other):
                return (self.__ns in dependency_map.get(
                    other.__ns,
                    set())) == (other.__ns
                                in dependency_map.get(self.__ns, set()))

            # All other order metrics are derived.
            def __ne__(self, other):
                return not self.__eq__(other)

            def __le__(self, other):
                return self.__lt__(other) or self.__eq__(other)

            def __gt__(self, other):
                return other.__lt__(self.__ns)

            def __ge__(self, other):
                return other.__lt__(self.__ns) or self.__eq__(other)

        return K

    need_resolved_set = set(sibling_namespaces)
    dependency_map = {}
    last_state = None
    while need_resolved_set:
        need_resolved_list = list(need_resolved_set)
        if dependency_map:
            need_resolved_list.sort(key=__keyForCompare(dependency_map))
        need_resolved_set = set()
        dependency_map = {}
        for ns in need_resolved_list:
            if not ns.needsResolution():
                continue
            if not ns.resolveDefinitions(allow_unresolved=True):
                deps = dependency_map.setdefault(ns, set())
                for (c, dcs) in six.iteritems(ns._unresolvedDependents()):
                    for dc in dcs:
                        dns = dc.expandedName().namespace()
                        if dns != ns:
                            deps.add(dns)
                _log.info(
                    'Holding incomplete resolution %s depending on: ',
                    ns.uri(),
                    six.u(' ; ').join([six.text_type(_dns) for _dns in deps]))
                need_resolved_set.add(ns)
        # Exception termination check: if we have the same set of incompletely
        # resolved namespaces, and each has the same number of unresolved
        # components, assume there's an truly unresolvable dependency: either
        # due to circularity, or because there was an external namespace that
        # was missed from the sibling list.
        state = []
        for ns in need_resolved_set:
            state.append((ns, len(ns._unresolvedComponents())))
        state = tuple(state)
        if last_state == state:
            raise pyxb.LogicError(
                'Unexpected external dependency in sibling namespaces: %s' %
                (six.u('\n  ').join(
                    [six.text_type(_ns) for _ns in need_resolved_set]), ))
        last_state = state
Exemple #30
0
def MakeCamelCase(identifier):
    return _CamelCase_re.sub(lambda _m: _m.group(0)[1].upper(),
                             six.text_type(identifier))
Exemple #31
0
 def __unicode__(self):
     return six.text_type(self.get_mvn_str())
Exemple #32
0
def MakeCamelCase (identifier):
    return _CamelCase_re.sub(lambda _m: _m.group(0)[1].upper(), six.text_type(identifier))