-=c@sdZddlZddlZddlZddlZddlZddlZddlZddlZddl Z yej ej gZ Wne k rej gZ nXyCddlZdZiZdZdZeZeddZWn2ek rdZeZd ZeZeZnXd efd YZd fd YZdefdYZdZdZ dZ!dZ"ej#dkre"Z$ne!Z$erej%Z&nd Z&ddZ'e'dZ(dZ)ej*de&Z+ej*de&Z,ej*dZ-ej*dZ.er{ddl/m0Z0e0j1Z2e0j3Z4e0j5Z6e0j7Z8ej*de0j9dZ:[0nej*d e'd!e(d"Z2ej*d e'd!e(d#e'd!e(d$Z4ej*d e(d%Z6ej*d e(d&e(d'Z8ej*d(e'd!e(d)Z:ej*d*Z;ej*d+Z<ej*d,Z=ej*d-Z>ej*d.Z?ej*d/Z@ej*d0ZAej*d1ZBej*d2ZCej*d3ZDej*d4ZEej*d5ZFej*d6ZGej*d7ZHej*d8ejIZJej*d9ZKej*d:ZLej*d;ZMej*d<ZNej*d=ZOej*d>ZPej*d?ZQej*d@ZRi dAe2jS6dBe,jS6dCe-jS6dDe.jS6dEeHjS6dFeGjS6dGe:jS6dHeEjS6dIeFjS6dJe6jS6ZTidKdL6dMdN6dOdP6dQdR6dSdT6ZUerDx(eUjVD]ZWeeUeWeUeWsicSs||dS(Ni((tctd((sN/opt/freeware/lib/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmlutils.pyRsicSs|||ddS(Ni((RRte((sN/opt/freeware/lib/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmlutils.pyR sicSs|S(N((R((sN/opt/freeware/lib/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmlutils.pyR#s(tcodecstlookuptNonet LookupErrort report_error(tparsertsrctdesttenctdecodertencoder((sN/opt/freeware/lib/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmlutils.pyt mkconverters    cCs/t|tjkrt|Stj||S(N(ttypettypest StringTypetinternt _internedt setdefault(tx((sN/opt/freeware/lib/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmlutils.pyt string_intern%s iss utf-16-becCsX|dkrd}ntjj||r=tjj||S|jd|dSdS(Nsutf-8icSs|S(N((R((sN/opt/freeware/lib/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmlutils.pyR4s(Rtcharconvtconvdbt can_convertt get_converterR (R R R ((sN/opt/freeware/lib/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmlutils.pyR-s   itOutOfDataExceptioncBseZdZRS(sdAn exception that signals that more data is expected, but the current buffer has been exhausted.(t__name__t __module__t__doc__(((sN/opt/freeware/lib/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmlutils.pyR=st EntityParsercBseZdZdZdZdZdZdZdZdZ dd Z d2d2d Z d d Z d d ZdZddZdZdZdZddZdZdZdZdZdZdZdZdZddZdZd Zd!Z d"Z!dd#Z"d$Z#d%Z$d&Z%d'Z&d2d(Z'd)Z(d*Z)d+Z*d,Z+d-Z,d.Z-d/Z.d d0Z/d1Z0RS(3sXA generalized parser for XML entities, whether DTD, documents or even catalog files.cCstj||_tj|j|_tj|_tj|_d|_ d|_ d|_ d|_ tj|j |_|jdS(Nten(txmlappt ErrorHandlerterrt EntityHandlertenttInputSourceFactorytisft PubIdResolvertpubresRt data_charsettinput_encodingtcharset_converterterr_langterrorstget_error_listtreset(tself((sN/opt/freeware/lib/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmlutils.pyt__init__Js    cCs1tjtj||_tj||_dS(s}Sets the language in which errors are reported. (ISO 3166 codes.) Throws a KeyError if the language is not supported.N(R0R1tstringtlowerR/(R3tlanguage((sN/opt/freeware/lib/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmlutils.pytset_error_languageYscCs ||_dS(s(Sets the object to send error events to.N(R%(R3R%((sN/opt/freeware/lib/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmlutils.pytset_error_handler_scCs ||_dS(N(R+(R3R+((sN/opt/freeware/lib/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmlutils.pytset_pubid_resolvercscCs ||_dS(s0Sets the object that resolves entity references.N(R'(R3R'((sN/opt/freeware/lib/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmlutils.pytset_entity_handlerfscCs ||_dS(sASets the object factory used to create input sources from sysids.N(R)(R3R)((sN/opt/freeware/lib/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmlutils.pytset_inputsource_factoryjscCs ||_dS(sTells the parser which character encoding to use when reporting data to applications. The default is None, which means to return Unicode string if supported and UTF-8 otherwise.N(R,(R3tcharset((sN/opt/freeware/lib/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmlutils.pytset_data_charsetnsi@cCsr||_y|jj|}Wn(ttfk rI|jd|dSX|j|||j|jdS(sBegin parsing an XML entity with the specified system identifier. Only used for the document entity, not to handle subentities, which open_entity takes care of.i N(t current_sysIDR)tcreate_input_sourcetIOErrortOSErrorR t read_fromtclose(R3tsysIDtbufsizetinfile((sN/opt/freeware/lib/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmlutils.pytparse_resourcets  cCs-|r||_n|j||jdS(s*Parse an XML document from the doc string.N(R?tfeedRD(R3tdoctsysidtpubid((sN/opt/freeware/lib/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmlutils.pyt parse_strings  RcCsy|jj|}Wn(ttfk r@|jd|dSX|j|||_d|_d|_d|_ d|_ d|_ d|_ d|_|j}d|_|j|d||_|j|jdS(sStarts parsing a new entity, pushing the old onto the stack. This method must not be used to start parsing, use parse_resource for that. Note that sys_id must be absolute.i Niiti(R)R@RARBR t_push_ent_stackR?tpostlinet last_breaktdatat encoded_dataRR-R.t seen_xmldeclRCtflusht pop_entity(R3tsys_idtnametinfttmp((sN/opt/freeware/lib/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmlutils.pyt open_entitys(             cCsh|j|||_d|_||_d|_d|_d|_t||_d|_ d|_ dS(spParse some text and consider it a new entity, making it possible to return to the original entity later.RNiiN( RORSRTR?RPRQRRtlentdatasizet last_upd_postfinal(R3REtcontentsRY((sN/opt/freeware/lib/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmlutils.pyt push_entitys        cCs-|jgkr|jdn|jdS(s=Skips out of the current entity and back to the previous one.iN(t ent_stackR t_pop_ent_stack(R3((sN/opt/freeware/lib/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmlutils.pyRWscCsOxH|j|}|dkr"Pny|j|Wqtk rGPqXqdS(sReads data from a file-like object until EOF. Does not close it. **WARNING**: This method does not call the parseStart/parseEnd methods, since it does not know if it may be called several times. Use parse_resource if you just want to read a file.RNN(treadRIR(R3tfileobjRFtbuf((sN/opt/freeware/lib/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmlutils.pyRCs  cCsg|_g|_d|_d|_d|_d|_d|_d|_d|_d|_ d|_ d|_ d|_ d|_ dS(s/Resets the parser, losing all unprocessed data.tUnknowniRNiiN(Rct open_entsR?t first_feedRSRTR`R^t start_pointRQRRt block_offsetRPR_(R3((sN/opt/freeware/lib/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmlutils.pyR2s             cCst|dkrd}n|d dkr4d}n|d dkrMd}n|d dkrfd }n|d d krd }nq|d d krd}nX|d dkrd }n?|d dkrd }n&|d dkrd|_dSd}||_t|||j|_dS(Nisutf-8isitRHRRMR\RbRWRCR2RqRuRIRDRxR~RVRRRRRRRRRRRRRyRR RRRRRRRRORd(((sN/opt/freeware/lib/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmlutils.pyR!Fs\              !  3                       tXMLCommonParsercBsSeZdddZdZd dZddZdZdZdZ RS( iicCsud}d}|jdrL|jd|jdtfdtfg}n|jdrU|jd|jdtfdtfg}tj tj |}|r|jd|jdtfdtfg}qk|j ds|j dr|j dn|j|j ds.|j drk|jdtfdtfg}qkn|rk|j dn||fS( sParses an external ID declaration and returns a tuple consisting of (pubid,sysid). If the required attribute is false neither SYSTEM nor PUBLIC identifiers are required. If sysidreq is false a SYSTEM identifier is not required after a PUBLIC one.tSYSTEMis"t'tPUBLICi i N( RRRRtreg_sysid_quotet reg_sysid_apotreg_pubid_quotet reg_pubid_apoR5tjointsplitRR (R3Rtsysidreqtpub_idRX((sN/opt/freeware/lib/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmlutils.pytparse_external_idFs0    cCs}y|j|j}Wntk r0tnX|jdpL|jdsp|jdd|jddS|j|S(s<Returns the contents of a quoted string at current position.t"Ri s'"'t>RN(s'"'R(RSRPt IndexErrorRRR R(R3tquo((sN/opt/freeware/lib/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmlutils.pyt__get_quoted_stringis   c Cs|j}|j|jdksP|jdksP|jgkrv| rv|rf|jdqv|jdn|jr|r|jdq|jdnd}d}d}|j|j dr|j|j ds|jd dn|j|j }t j |}|dksE|j t|krX|jd |n|d krt|jd n|jd s|jdr|jdn|jn|s|jdn|j d r|j|j ds|jd dn|j|j }tj |dkr;|jdntj|}|jru|j|kru|jd|n|jn|j dr0|r|jdd}q0|j|j ds|jd dn|j|j }tj |dkr|jdn|dk|_|jn|j|js|}|sXd}nt|||j|_y|j|j|_Wn&tk r}|j|j|nX||_n|dkr|j|||ndS(sBParses the contents of the XML declaration from after the 'i i tyesiGsutf-8N(RRyRRRcR RURRRt#_XMLCommonParser__get_quoted_stringtreg_verRRR]Rt reg_enc_nameR5R6R-t reg_std_aloneRRR,R.RSRsRutset_entity_info( R3thandlerttextdeclR tsddecltvertmtenc1R((sN/opt/freeware/lib/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmlutils.pytparse_xml_declws  $     $                 cCs|j}|dkrf|r.|j|n |j|jdsZ|jddnd|_n|jdr~d}n|jd|jd}tj|d kr|dkr|jdq|dkr|jd qn|j ||d S( sOParses a processing instruction from after the ''.txmls?>i iRNs xml:namespaceisxml-stylesheeti N( t _get_nameRRR RURRt reg_res_piRRt handle_pi(R3Rtreport_xml_declttrgttrem((sN/opt/freeware/lib/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmlutils.pytparse_pis$        cCsX|jd}|j|j|j|!||_|jdsT|jddndS(s5Parses the comment from after ''.s--s-->i N(Rthandle_commentRSRPRR (R3RR((sN/opt/freeware/lib/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmlutils.pyt parse_comments  c Cs|jdr't|jt}nt|jt}|dkpu|dkpu|dkpu|dkou|dks|dkrtr|dkr|jjt |dd q|j d |n|j d |d St |Sd S(s7Parses a character reference and returns the character.Ri i i i iiiiii RNN( RtunhexRtreg_hex_digitstintt reg_digitsRvtappt handle_datatxml_chrR (R3tdigs((sN/opt/freeware/lib/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmlutils.pyt_read_char_refs$ cCs|j|jdkr,|j r,tntj|j|j}|r|j|_|j|jkr|j rtnt|j S|j ddSdS(skParses the name at the current position and returns it. An error is reported if no name is present.ii<RNN( RPR^R`Rtreg_nameRRSRRRR (R3R((sN/opt/freeware/lib/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmlutils.pyRs    N( RRRRRRRRRR(((sN/opt/freeware/lib/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmlutils.pyRDs#  c   cCsd}x|D]}|d}t|}|dkrR|dkrR||d}q |dkr{|dkr{||d}q |dkr |d kr ||d }q q W|S( s*Converts a string hex-value to an integer.iii:i0iaifiWiAiFi7(tord(t hex_valuetsumtchar((sN/opt/freeware/lib/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmlutils.pyR(s   cCs:|j|}|dko9t|jdt|kS(Ni(RRR]R(RRrR((sN/opt/freeware/lib/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmlutils.pytmatches:scCstj|ddkr|Stj|ddkrytj|ddkrrtjjtjj|d|S|Sntj||SdS(s<Resolves a URL relative to a base URL. The base can be None.iRNN(turlparsetostpathRRturljoin(tbaseturl((sN/opt/freeware/lib/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmlutils.pytjoin_sysids_general>s#cCstj|ddkr|Sttj|ddkrttj|ddkr~tjjtjj|d|S|Sntj||SdS(s<Resolves a URL relative to a base URL. The base can be None.iRNiN(RR]RRRRR(RR((sN/opt/freeware/lib/python2.7/site-packages/_xmlplus/parsers/xmlproc/xmlutils.pytjoin_sysids_win32Js#twin32s6ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_:s>s 0123456789.-s s[ ]+s[-a-zA-Z0-9_.:]+s[A-Za-z][-A-Za-z0-9._]*syes|no(t characterst%t;t[s][s]*s ]*([ ]+[s]*)*s]+s ]+([ ]+[s]+)*s%[s]*;s[^"]*s[^']*s#[- a-zA-Z0-9'()+,./:=?;!*#@$_%]*s"[- a-zA-Z0-9()+,./:=?;!*#@$_%]*s <[A-Za-z_:]s[^<"]*s[^<']*s[<&]s[^"]+s[^']+s6CDATA|IDREFS|IDREF|ID|ENTITY|ENTITIES|NMTOKENS|NMTOKENs#REQUIRED|#IMPLIEDs[0-9]+s [0-9a-fA-F]+Rs"|'|<\?|