Browse Source

fixing other malformed exceptions

main
Julien Iguchi-Cartigny 10 years ago
parent
commit
a645ba64d2
2 changed files with 9 additions and 9 deletions
  1. +4
    -4
      wstools/Utility.py
  2. +5
    -5
      wstools/XMLSchema.py

+ 4
- 4
wstools/Utility.py View File

@@ -863,7 +863,7 @@ class ElementProxy(Base, MessageInterface):
prefix = 'ns%d' % self._indx
try:
self._dom.findNamespaceURI(prefix, self._getNode())
except DOMException, ex:
except DOMException as ex:
break
return prefix

@@ -877,7 +877,7 @@ class ElementProxy(Base, MessageInterface):
if node and (node.nodeType == node.ELEMENT_NODE) and \
(nsuri == self._dom.findDefaultNS(node)):
return None
except DOMException, ex:
except DOMException as ex:
pass
if nsuri == XMLNS.XML:
return self._xml_prefix
@@ -928,7 +928,7 @@ class ElementProxy(Base, MessageInterface):
def getPrefix(self, namespaceURI):
try:
prefix = self._getPrefix(node=self.node, nsuri=namespaceURI)
except NamespaceError, ex:
except NamespaceError as ex:
prefix = self._getUniquePrefix()
self.setNamespaceAttribute(prefix, namespaceURI)
return prefix
@@ -1025,7 +1025,7 @@ class ElementProxy(Base, MessageInterface):
if namespaceURI:
try:
prefix = self.getPrefix(namespaceURI)
except KeyError, ex:
except KeyError as ex:
prefix = 'ns2'
self.setNamespaceAttribute(prefix, namespaceURI)
qualifiedName = localName


+ 5
- 5
wstools/XMLSchema.py View File

@@ -289,7 +289,7 @@ class DOMAdapter(DOMAdapterInterface):
else:
try:
namespace = DOM.findNamespaceURI(prefix, self.__node)
except DOMException, ex:
except DOMException as ex:
if prefix != 'xml':
raise SchemaError('%s namespace not declared for %s' % (prefix, self.__node._get_tagName()))
namespace = XMLNS.XML
@@ -629,7 +629,7 @@ class XMLSchemaComponent(XMLBase, MarkerInterface):
if parent.targetNamespace == namespace:
try:
obj = getattr(parent, collection)[name]
except KeyError, ex:
except KeyError as ex:
raise KeyError('targetNamespace(%s) collection(%s) has no item(%s)' % (namespace, collection, name))

return obj
@@ -662,7 +662,7 @@ class XMLSchemaComponent(XMLBase, MarkerInterface):

try:
obj = getattr(schema, collection)[name]
except KeyError, ex:
except KeyError as ex:
raise KeyError('targetNamespace(%s) collection(%s) has no item(%s)' % (namespace, collection, name))

return obj
@@ -1228,13 +1228,13 @@ class XMLSchema(XMLSchemaComponent):
slocd[import_ns] = schema
try:
tp.loadSchema(schema)
except NoSchemaLocationWarning, ex:
except NoSchemaLocationWarning as ex:
# Dependency declaration, hopefully implementation
# is aware of this namespace (eg. SOAP,WSDL,?)
self.logger.debug("IMPORT: %s : %s" % (import_ns, ex))
del slocd[import_ns]
continue
except SchemaError, ex:
except SchemaError as ex:
#warnings.warn(\
# '<import namespace="%s" schemaLocation=?>, %s'\
# %(import_ns, 'failed to load schema instance')


Loading…
Cancel
Save