Example #1
0
 def print_dictionary(self, d, h, n, nl=False):
     """ print complex using the specified indent (n) and newline (nl). """
     if d in h:
         return '{}...'
     h.append(d)
     s = []
     if nl:
         s.append('\n')
         s.append(self.indent(n))
     s.append('{')
     for item in d.items():
         s.append('\n')
         s.append(self.indent(n + 1))
         if isinstance(item[1], (list, tuple)):
             s.append(tostr(item[0]))
             s.append('[]')
         else:
             s.append(tostr(item[0]))
         s.append(' = ')
         s.append(self.process(item[1], h, n, True))
     s.append('\n')
     s.append(self.indent(n))
     s.append('}')
     h.pop()
     return ''.join(s)
Example #2
0
 def print_dictionary(self, d, h, n, nl=False):
     """ print complex using the specified indent (n) and newline (nl). """
     if d in h:
         return '{}...'
     h.append(d)
     s = []
     if nl:
         s.append('\n')
         s.append(self.indent(n))
     s.append('{')
     for item in d.items():
         s.append('\n')
         s.append(self.indent(n + 1))
         if isinstance(item[1], (list, tuple)):
             s.append(tostr(item[0]))
             s.append('[]')
         else:
             s.append(tostr(item[0]))
         s.append(' = ')
         s.append(self.process(item[1], h, n, True))
     s.append('\n')
     s.append(self.indent(n))
     s.append('}')
     h.pop()
     return ''.join(s)
Example #3
0
 def append(self, parent, content):
     if content.tag.startswith('_'):
         attr = content.tag[1:]
         value = tostr(content.value)
         if value:
             parent.set(attr, value)
     else:
         child = self.node(content)
         child.setText(tostr(content.value))
         parent.append(child)
Example #4
0
 def append(self, parent, content):
     if content.tag.startswith('_'):
         attr = content.tag[1:]
         value = tostr(content.value)
         if value:
             parent.set(attr, value)
     else:
         child = self.node(content)
         child.setText(tostr(content.value))
         parent.append(child)
Example #5
0
 def __init__(self, ref=None):
     """
     @param ref: The schema reference being queried.
     @type ref: qref
     """
     Object.__init__(self)
     self.id = objid(self)
     self.ref = ref
     self.history = []
     self.resolved = False
     if not isqref(self.ref):
         raise Exception('%s, must be qref' % tostr(self.ref))
Example #6
0
 def __init__(self, ref=None):
     """
     @param ref: The schema reference being queried.
     @type ref: qref
     """
     Object.__init__(self)
     self.id = objid(self)
     self.ref = ref
     self.history = []
     self.resolved = False
     if not isqref(self.ref):
         raise Exception('%s, must be qref' % tostr(self.ref))
Example #7
0
 def process(self, object, h, n=0, nl=False):
     """ print object using the specified indent (n) and newline (nl). """
     if object is None:
         return 'None'
     if isinstance(object, Object):
         if len(object) == 0:
             return '<empty>'
         else:
             return self.print_object(object, h, n + 2, nl)
     if isinstance(object, dict):
         if len(object) == 0:
             return '<empty>'
         else:
             return self.print_dictionary(object, h, n + 2, nl)
     if isinstance(object, (list, tuple)):
         if len(object) == 0:
             return '<empty>'
         else:
             return self.print_collection(object, h, n + 2)
     if isinstance(object, six.string_types):
         return '"%s"' % tostr(object)
     return '%s' % tostr(object)
Example #8
0
 def process(self, object, h, n=0, nl=False):
     """ print object using the specified indent (n) and newline (nl). """
     if object is None:
         return 'None'
     if isinstance(object, Object):
         if len(object) == 0:
             return '<empty>'
         else:
             return self.print_object(object, h, n + 2, nl)
     if isinstance(object, dict):
         if len(object) == 0:
             return '<empty>'
         else:
             return self.print_dictionary(object, h, n + 2, nl)
     if isinstance(object, (list, tuple)):
         if len(object) == 0:
             return '<empty>'
         else:
             return self.print_collection(object, h, n + 2)
     if isinstance(object, six.string_types):
         return '"%s"' % tostr(object)
     return '%s' % tostr(object)
Example #9
0
 def failed(self, binding, error):
     """
     Request failed, process reply based on reason
     @param binding: The binding to be used to process the reply.
     @type binding: L{suds.bindings.binding.Binding}
     @param error: The http error message
     @type error: L{transport.TransportError}
     """
     status, reason = (error.httpcode, suds.tostr(error))
     reply = error.fp.read()
     log.debug('http failed:\n%s', reply)
     if status == 500:
         if len(reply) > 0:
             r, p = binding.get_fault(reply)
             self.last_received(r)
             return (status, p)
         else:
             return (status, None)
     if self.options.faults:
         raise Exception((status, reason))
     else:
         return (status, None)
Example #10
0
 def failed(self, binding, error):
     """
     Request failed, process reply based on reason
     @param binding: The binding to be used to process the reply.
     @type binding: L{suds.bindings.binding.Binding}
     @param error: The http error message
     @type error: L{transport.TransportError}
     """
     status, reason = (error.httpcode, suds.tostr(error))
     reply = error.fp.read()
     log.debug('http failed:\n%s', reply)
     if status == 500:
         if len(reply) > 0:
             r, p = binding.get_fault(reply)
             self.last_received(r)
             return (status, p)
         else:
             return (status, None)
     if self.options.faults:
         raise Exception((status, reason))
     else:
         return (status, None)
 def html(self):
     try:
         return self.description(html=True)
     except Exception as e:
         log.exception(e)
     return tostr(e)
 def __str__(self):
     try:
         return self.description()
     except Exception as e:
         log.exception(e)
     return tostr(e)
Example #13
0
 def __unicode__(self):
     try:
         return self.description()
     except Exception as e:
         log.exception(e)
     return tostr(e)
 def html(self):
     try:
         return self.description(html=True)
     except Exception as e:
         log.exception(e)
         return tostr(e)