<s> '''<STR_LIT>''' <EOL> _copyright = """<STR_LIT>""" <EOL> from xml . dom import Node as _Node <EOL> from pysphere . ZSI . wstools . Namespaces import ZSI_SCHEMA_URI <EOL> UNICODE_ENCODING = '<STR_LIT:utf-8>' <EOL> _inttypes = ( int , long ) <EOL> _floattypes = ( float , ) <EOL> _seqtypes = ( tuple , list ) <EOL> _stringtypes = ( str , unicode ) <EOL> _attrs = lambda E : ( E . attributes and E . attributes . values ( ) ) or [ ] <EOL> _children = lambda E : E . childNodes or [ ] <EOL> _child_elements = lambda E : [ n for n in ( E . childNodes or [ ] ) <EOL> if n . nodeType == _Node . ELEMENT_NODE ] <EOL> from pysphere . ZSI . wstools . Namespaces import SOAP as _SOAP , SCHEMA as _SCHEMA , XMLNS as _XMLNS <EOL> _find_arraytype = lambda E : E . getAttributeNS ( _SOAP . ENC , "<STR_LIT>" ) <EOL> _find_encstyle = lambda E : E . getAttributeNS ( _SOAP . ENV , "<STR_LIT>" ) <EOL> try : <EOL> from xml . dom import EMPTY_NAMESPACE <EOL> _empty_nsuri_list = [ EMPTY_NAMESPACE ] <EOL> except : <EOL> _empty_nsuri_list = [ None , '<STR_LIT>' ] <EOL> def _find_attr ( E , attr ) : <EOL> for nsuri in _empty_nsuri_list : <EOL> try : <EOL> v = E . getAttributeNS ( nsuri , attr ) <EOL> if v : return v <EOL> except : pass <EOL> return None <EOL> def _find_attrNS ( E , namespaceURI , localName ) : <EOL> '''<STR_LIT>''' <EOL> try : <EOL> v = E . getAttributeNS ( namespaceURI , localName ) <EOL> if v : return v <EOL> except : pass <EOL> return None <EOL> def _find_attrNodeNS ( E , namespaceURI , localName ) : <EOL> '''<STR_LIT>''' <EOL> attr = E . getAttributeNodeNS ( namespaceURI , localName ) <EOL> if attr is None : return None <EOL> try : <EOL> return attr . value <EOL> except : pass <EOL> return E . getAttributeNS ( namespaceURI , localName ) <EOL> _find_href = lambda E : _find_attr ( E , "<STR_LIT>" ) <EOL> _find_xsi_attr = lambda E , attr : E . getAttributeNS ( _SCHEMA . XSI3 , attr ) or E . getAttributeNS ( _SCHEMA . XSI1 , attr ) or E . getAttributeNS ( _SCHEMA . XSI2 , attr ) <EOL> _find_type = lambda E : _find_xsi_attr ( E , "<STR_LIT:type>" ) <EOL> _find_xmlns_prefix = lambda E , attr : E . getAttributeNS ( _XMLNS . BASE , attr ) <EOL> _find_default_namespace = lambda E : E . getAttributeNS ( _XMLNS . BASE , '<STR_LIT>' ) <EOL> _textprotect = lambda s : s . replace ( '<STR_LIT:&>' , '<STR_LIT>' ) . replace ( '<STR_LIT:<>' , '<STR_LIT>' ) <EOL> _get_element_nsuri_name = lambda E : ( E . namespaceURI , E . localName ) <EOL> _is_element = lambda E : E . nodeType == _Node . ELEMENT_NODE <EOL> def _resolve_prefix ( celt , prefix ) : <EOL> '''<STR_LIT>''' <EOL> while _is_element ( celt ) : <EOL> if prefix : <EOL> namespaceURI = _find_xmlns_prefix ( celt , prefix ) <EOL> else : <EOL> namespaceURI = _find_default_namespace ( celt ) <EOL> if namespaceURI : break <EOL> celt = celt . parentNode <EOL> else : <EOL> if prefix : <EOL> raise EvaluateException ( '<STR_LIT>' % prefix ) <EOL> return namespaceURI <EOL> def _valid_encoding ( elt ) : <EOL> '''<STR_LIT>''' <EOL> enc = _find_encstyle ( elt ) <EOL> if not enc or enc == _SOAP . ENC : return <NUM_LIT:1> <EOL> for e in enc . split ( ) : <EOL> if e . startswith ( _SOAP . ENC ) : <EOL> return <NUM_LIT:1> <EOL> return <NUM_LIT:0> <EOL> def _backtrace ( elt , dom ) : <EOL> '''<STR_LIT>''' <EOL> s = '<STR_LIT>' <EOL> while elt != dom : <EOL> name , parent = elt . nodeName , elt . parentNode <EOL> if parent is None : break <EOL> matches = [ c for c in _child_elements ( parent ) <EOL> if c . nodeName == name ] <EOL> if len ( matches ) == <NUM_LIT:1> : <EOL> s = '<STR_LIT:/>' + name + s <EOL> else : <EOL> i = matches . index ( elt ) + <NUM_LIT:1> <EOL> s = ( '<STR_LIT>' % ( name , i ) ) + s <EOL> elt = parent <EOL> return s <EOL> def _get_idstr ( pyobj ) : <EOL> '''<STR_LIT>''' <EOL> x = id ( pyobj ) <EOL> if x < <NUM_LIT:0> : <EOL> return '<STR_LIT>' % abs ( x ) <EOL> return '<STR_LIT>' % x <EOL> def _get_postvalue_from_absoluteURI ( url ) : <EOL> """<STR_LIT>""" <EOL> cache = _get_postvalue_from_absoluteURI . cache <EOL> path = cache . get ( url , '<STR_LIT>' ) <EOL> if not path : <EOL> _ , authpath = url . split ( '<STR_LIT>' ) <EOL> s = authpath . split ( '<STR_LIT:/>' , <NUM_LIT:1> ) <EOL> if len ( s ) == <NUM_LIT:2> : path = '<STR_LIT>' % s [ <NUM_LIT:1> ] <EOL> if len ( cache ) > _get_postvalue_from_absoluteURI . MAXLEN : cache . clear ( ) <EOL> cache [ url ] = path <EOL> return path <EOL> _get_postvalue_from_absoluteURI . cache = { } <EOL> _get_postvalue_from_absoluteURI . MAXLEN = <NUM_LIT:20> <EOL> class ZSIException ( Exception ) : <EOL> '''<STR_LIT>''' <EOL> pass <EOL> class ParseException ( ZSIException ) : <EOL> '''<STR_LIT>''' <EOL> def __init__ ( self , _str , inheader , elt = None , dom = None ) : <EOL> Exception . __init__ ( self ) <EOL> self . str , self . inheader , self . trace = _str , inheader , None <EOL> if elt and dom : <EOL> self . trace = _backtrace ( elt , dom ) <EOL> def __str__ ( self ) : <EOL> if self . trace : <EOL> return self . str + '<STR_LIT>' + self . trace + '<STR_LIT:]>' <EOL> return self . str <EOL> def __repr__ ( self ) : <EOL> return "<STR_LIT>" % ( __name__ , _get_idstr ( self ) ) <EOL> class EvaluateException ( ZSIException ) : <EOL> '''<STR_LIT>''' <EOL> def __init__ ( self , _str , trace = None ) : <EOL> Exception . __init__ ( self ) <EOL> self . str , self . trace = _str , trace <EOL> def __str__ ( self ) : <EOL> if self . trace : <EOL> return self . str + '<STR_LIT>' + self . trace + '<STR_LIT:]>' <EOL> return self . str <EOL> def __repr__ ( self ) : <EOL> return "<STR_LIT>" % ( __name__ , _get_idstr ( self ) ) <EOL> class FaultException ( ZSIException ) : <EOL> '''<STR_LIT>''' <EOL> def __init__ ( self , fault ) : <EOL> self . fault = fault <EOL> def __str__ ( self ) : <EOL> return str ( self . fault ) <EOL> def __repr__ ( self ) : <EOL> return "<STR_LIT>" % ( __name__ , _get_idstr ( self ) ) <EOL> class WSActionException ( ZSIException ) : <EOL> '''<STR_LIT>''' <EOL> pass <EOL> def Version ( ) : <EOL> from pysphere . ZSI import version <EOL> return version . Version <EOL> from pysphere . ZSI . writer import SoapWriter <EOL> from pysphere . ZSI . parse import ParsedSoap <EOL> from pysphere . ZSI . fault import Fault , FaultFromActor , FaultFromException , FaultFromFaultMessage , FaultFromNotUnderstood , FaultFromZSIException <EOL> from pysphere . ZSI import TC <EOL> TC . RegisterType ( TC . String , minOccurs = <NUM_LIT:0> , nillable = False ) <EOL> TC . RegisterType ( TC . URI , minOccurs = <NUM_LIT:0> , nillable = False ) <EOL> TC . RegisterType ( TC . Base64String , minOccurs = <NUM_LIT:0> , nillable = False ) <EOL> TC . RegisterType ( TC . HexBinaryString , minOccurs = <NUM_LIT:0> , nillable = False ) <EOL> for pyclass in ( TC . IunsignedByte , TC . IunsignedShort , TC . IunsignedInt , TC . IunsignedLong , <EOL> TC . Ibyte , TC . Ishort , TC . Iint , TC . Ilong , TC . InegativeInteger , <EOL> TC . InonPositiveInteger , TC . InonNegativeInteger , TC . IpositiveInteger , <EOL> TC . Iinteger , TC . FPfloat , TC . FPdouble , ) : <EOL> TC . RegisterType ( pyclass , minOccurs = <NUM_LIT:0> , nillable = False ) <EOL> TC . RegisterType ( TC . Boolean , minOccurs = <NUM_LIT:0> , nillable = False ) <EOL> TC . RegisterType ( TC . Duration , minOccurs = <NUM_LIT:0> , nillable = False ) <EOL> TC . RegisterType ( TC . gDateTime , minOccurs = <NUM_LIT:0> , nillable = False ) <EOL> TC . RegisterType ( TC . gDate , minOccurs = <NUM_LIT:0> , nillable = False ) <EOL> TC . RegisterType ( TC . gYearMonth , minOccurs = <NUM_LIT:0> , nillable = False ) <EOL> TC . RegisterType ( TC . gYear , minOccurs = <NUM_LIT:0> , nillable = False ) <EOL> TC . RegisterType ( TC . gMonthDay , minOccurs = <NUM_LIT:0> , nillable = False ) <EOL> TC . RegisterType ( TC . gDay , minOccurs = <NUM_LIT:0> , nillable = False ) <EOL> TC . RegisterType ( TC . gTime , minOccurs = <NUM_LIT:0> , nillable = False ) <EOL> TC . RegisterType ( TC . Apache . Map , minOccurs = <NUM_LIT:0> , nillable = False ) <EOL> from pysphere . ZSI import schema <EOL> for i in [ int , float , str , tuple , list , unicode ] : <EOL> schema . _GetPyobjWrapper . RegisterBuiltin ( i ) <EOL> schema . RegisterAnyElement ( ) </s>
