Vega strike Python Modules doc  0.5.1
Documentation of the " Modules " folder of Vega strike
 All Data Structures Namespaces Files Functions Variables
Unmarshaller Class Reference

Public Member Functions

def __init__
 
def close
 
def getmethodname
 
def xml
 
def start
 
def data
 
def end
 
def end_dispatch
 
def end_boolean
 
def end_int
 
def end_double
 
def end_string
 
def end_array
 
def end_struct
 
def end_base64
 
def end_dateTime
 
def end_value
 
def end_params
 
def end_fault
 
def end_methodName
 

Data Fields

 append
 

Static Public Attributes

dictionary dispatch = {}
 

Detailed Description

Unmarshal an XML-RPC response, based on incoming XML event
messages (start, data, end).  Call close() to get the resulting
data structure.

Note that this reader is fairly tolerant, and gladly accepts bogus
XML-RPC data without complaining (but not bogus XML).

Definition at line 545 of file xmlrpclib.py.

Constructor & Destructor Documentation

def __init__ (   self)

Definition at line 557 of file xmlrpclib.py.

References Unmarshaller._data, Au_read._encoding, Unmarshaller._encoding, Unmarshaller._marks, Unmarshaller._methodname, Unmarshaller._stack, and Unmarshaller._type.

558  def __init__(self):
559  self._type = None
560  self._stack = []
561  self._marks = []
562  self._data = []
563  self._methodname = None
564  self._encoding = "utf-8"
565  self.append = self._stack.append

Member Function Documentation

def close (   self)

Definition at line 566 of file xmlrpclib.py.

References Unmarshaller._marks, Unmarshaller._stack, Unmarshaller._type, and log_faction_ships.tuple.

567  def close(self):
568  # return response tuple and target method
569  if self._type is None or self._marks:
570  raise ResponseError()
571  if self._type == "fault":
572  raise apply(Fault, (), self._stack[0])
573  return tuple(self._stack)
def data (   self,
  text 
)

Definition at line 591 of file xmlrpclib.py.

592  def data(self, text):
593  self._data.append(text)
def end (   self,
  tag,
  join = string.join 
)

Definition at line 594 of file xmlrpclib.py.

References Unmarshaller._data, Pickler.dispatch, Profile.dispatch, Marshaller.dispatch, Unpickler.dispatch, Unmarshaller.dispatch, aifc.f, and dospath.join().

595  def end(self, tag, join=string.join):
596  # call the appropriate end tag handler
597  try:
598  f = self.dispatch[tag]
599  except KeyError:
600  pass # unknown tag ?
601  else:
602  return f(self, join(self._data, ""))
def end_array (   self,
  data 
)

Definition at line 649 of file xmlrpclib.py.

References Unmarshaller._marks, Unmarshaller._stack, and Unmarshaller._value.

650  def end_array(self, data):
651  mark = self._marks[-1]
652  del self._marks[-1]
653  # map arrays to Python lists
654  self._stack[mark:] = [self._stack[mark:]]
self._value = 0
def end_base64 (   self,
  data 
)

Definition at line 669 of file xmlrpclib.py.

References Unmarshaller._value, Unmarshaller.append, and Unpickler.append.

670  def end_base64(self, data):
671  value = Binary()
672  value.decode(data)
673  self.append(value)
self._value = 0
def end_boolean (   self,
  data 
)

Definition at line 620 of file xmlrpclib.py.

References Unmarshaller._value, Unmarshaller.append, and Unpickler.append.

621  def end_boolean(self, data):
622  if data == "0":
623  self.append(False)
624  elif data == "1":
625  self.append(True)
626  else:
627  raise TypeError, "bad boolean value"
self._value = 0
def end_dateTime (   self,
  data 
)

Definition at line 676 of file xmlrpclib.py.

References Unmarshaller.append, and Unpickler.append.

677  def end_dateTime(self, data):
678  value = DateTime()
679  value.decode(data)
self.append(value)
def end_dispatch (   self,
  tag,
  data 
)

Definition at line 606 of file xmlrpclib.py.

References Pickler.dispatch, Profile.dispatch, Marshaller.dispatch, Unpickler.dispatch, Unmarshaller.dispatch, and aifc.f.

607  def end_dispatch(self, tag, data):
608  # dispatch data
609  try:
610  f = self.dispatch[tag]
611  except KeyError:
612  pass # unknown tag ?
613  else:
614  return f(self, data)
def end_double (   self,
  data 
)

Definition at line 636 of file xmlrpclib.py.

References Unmarshaller._value, Unmarshaller.append, and Unpickler.append.

637  def end_double(self, data):
638  self.append(float(data))
self._value = 0
def end_fault (   self,
  data 
)

Definition at line 693 of file xmlrpclib.py.

References Unmarshaller._type.

694  def end_fault(self, data):
self._type = "fault"
def end_int (   self,
  data 
)

Definition at line 630 of file xmlrpclib.py.

References Unmarshaller._value, Unmarshaller.append, and Unpickler.append.

631  def end_int(self, data):
632  self.append(int(data))
self._value = 0
def end_methodName (   self,
  data 
)

Definition at line 697 of file xmlrpclib.py.

References Au_read._encoding, Unmarshaller._encoding, Unmarshaller._methodname, and Unmarshaller._type.

698  def end_methodName(self, data):
699  if self._encoding:
700  data = _decode(data, self._encoding)
701  self._methodname = data
self._type = "methodName" # no params
def end_params (   self,
  data 
)

Definition at line 689 of file xmlrpclib.py.

References Unmarshaller._type.

690  def end_params(self, data):
self._type = "params"
def end_string (   self,
  data 
)

Definition at line 641 of file xmlrpclib.py.

References Au_read._encoding, Unmarshaller._encoding, Unmarshaller._value, Unmarshaller.append, and Unpickler.append.

642  def end_string(self, data):
643  if self._encoding:
644  data = _decode(data, self._encoding)
645  self.append(_stringify(data))
self._value = 0
def end_struct (   self,
  data 
)

Definition at line 657 of file xmlrpclib.py.

References Unmarshaller._marks, Unmarshaller._stack, and Unmarshaller._value.

658  def end_struct(self, data):
659  mark = self._marks[-1]
660  del self._marks[-1]
661  # map structs to Python dictionaries
662  dict = {}
663  items = self._stack[mark:]
664  for i in range(0, len(items), 2):
665  dict[_stringify(items[i])] = items[i+1]
666  self._stack[mark:] = [dict]
self._value = 0
def end_value (   self,
  data 
)

Definition at line 682 of file xmlrpclib.py.

References Unmarshaller._value, and Unmarshaller.end_string().

683  def end_value(self, data):
684  # if we stumble upon an value element with no internal
685  # elements, treat it as a string element
686  if self._value:
self.end_string(data)
def getmethodname (   self)

Definition at line 574 of file xmlrpclib.py.

References Unmarshaller._methodname.

575  def getmethodname(self):
576  return self._methodname
def start (   self,
  tag,
  attrs 
)

Definition at line 584 of file xmlrpclib.py.

References Unmarshaller._data, Unmarshaller._stack, and Unmarshaller._value.

585  def start(self, tag, attrs):
586  # prepare to handle this element
587  if tag == "array" or tag == "struct":
588  self._marks.append(len(self._stack))
589  self._data = []
590  self._value = (tag == "value")
def xml (   self,
  encoding,
  standalone 
)

Definition at line 580 of file xmlrpclib.py.

References Au_read._encoding, and Unmarshaller._encoding.

581  def xml(self, encoding, standalone):
582  self._encoding = encoding
583  # FIXME: assert standalone == 1 ???

Field Documentation

append

Definition at line 564 of file xmlrpclib.py.

dictionary dispatch = {}
static

Definition at line 618 of file xmlrpclib.py.


The documentation for this class was generated from the following file: