mò
â\bCc           @   s  d  Z  d Z d k Td k l Z l Z d k l Z d k l Z l Z d k l	 Z	 d k l
 Z
 l Z d k Z e i d	  d
 j o e d e ƒ ‚ n [ y d k l Z Wn" e j
 o e d e ƒ ‚ n& Xe e d ƒ o e d e ƒ ‚ n d k l Z l Z l Z e i Z e i Z y d k Z Wn e j
 o d „  Z n Xd k Z e i Z [ [ d e i f d „  ƒ  YZ d e i  e i f d „  ƒ  YZ! d „  Z" e# d j oO d k Z$ e" ƒ  Z% e% i& e$ i' i( ƒ  ƒ e% i) e$ i' i* ƒ  ƒ e% i+ d ƒ n d S(   s]   
SAX driver for the pyexpat C module.  This driver works with
pyexpat.__version__ == '2.22'.
s   0.20(   t   *(   s   feature_validations   feature_namespaces(   s   feature_namespace_prefixes(   s   feature_external_gess   feature_external_pes(   s   feature_string_interning(   s   property_xml_strings   property_interning_dictNi   t   javas   expat not available in Java(   s   expats   expat not supportedt   ParserCreate(   s	   xmlreaders   saxutilss   handlerc         C   s   |  S(   N(   t   o(   R   (    (    t   xml\sax\expatreader.pyct   _mkproxy'   s    t   ExpatLocatorc           B   s;   t  Z d  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   s¼   Locator for use with the ExpatParser class.

    This uses a weak reference to the parser object to avoid creating
    a circular reference between the parser and the content handler.
    c         C   s   t  | ƒ |  _ d  S(   N(   R   t   parsert   selft   _ref(   R   R   (    (    R   t   __init__6   s    c         C   s+   |  i } | i d  j o d  Sn | i i S(   N(   R   R	   R   t   _parsert   Nonet   ErrorColumnNumber(   R   R   (    (    R   t   getColumnNumber9   s    	c         C   s+   |  i } | i d  j o d Sn | i i S(   Ni   (   R   R	   R   R   R   t   ErrorLineNumber(   R   R   (    (    R   t   getLineNumber?   s    	c         C   s+   |  i } | d  j o d  Sn | i i ƒ  S(   N(   R   R	   R   R   t   _sourcet   getPublicId(   R   R   (    (    R   R   E   s    	c         C   s+   |  i } | d  j o d  Sn | i i ƒ  S(   N(   R   R	   R   R   R   t   getSystemId(   R   R   (    (    R   R   K   s    	(   t   __name__t
   __module__t   __doc__R
   R   R   R   R   (    (    (    R   R   0   s    				t   ExpatParserc           B   s-  t  Z d  Z d d d d d „ Z d „  Z d „  Z d „  Z d	 „  Z d
 „  Z d „  Z	 d „  Z
 d d „ Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d  „  Z d! „  Z d" „  Z  RS(#   s$   SAX driver for the pyexpat C module.i    i   i   i   c         C   se   t  i i |  | ƒ t  i ƒ  |  _ d  |  _ | |  _
 d  |  _ d |  _ g  |  _ d |  _ d  |  _ d  S(   Ni    i   (   t	   xmlreadert   IncrementalParserR
   R   t   bufsizet   InputSourceR   R   R   t   namespaceHandlingt   _namespacest   _lex_handler_propt   _parsingt   _entity_stackt   _external_gest
   _interning(   R   R   R   (    (    R   R
   W   s    						c         C   sO   t  i | ƒ } | |  _ |  i ƒ  |  i i t |  ƒ ƒ t	 i
 i |  | ƒ d S(   s3   Parse an XML document from a URL or an InputSource.N(   t   saxutilst   prepare_input_sourcet   sourceR   R   t   resett   _cont_handlert   setDocumentLocatorR   R   R   t   parse(   R   R%   (    (    R   R)   d   s     	
c         C   s1   | i ƒ  d  j o |  i i | i ƒ  ƒ n d  S(   N(   R%   R   R   R   R   t   SetBase(   R   R%   (    (    R   t   prepareParserm   s    c         C   s/   t  i i |  | ƒ |  i o |  i ƒ  n d  S(   N(   R   R   t   setContentHandlerR   t   handlerR   t   _reset_cont_handler(   R   R-   (    (    R   R,   s   s    
c         C   s€   | t j o |  i SnU | t j o |  i d  j	 Sn7 | t t t	 f j o d Sn | t
 j o |  i Sn t d | ƒ ‚ d  S(   Ni    s   Feature '%s' not recognized(   t   namet   feature_namespacesR   R   t   feature_string_interningR"   R   t   feature_validationt   feature_external_pest   feature_namespace_prefixest   feature_external_gesR!   t   SAXNotRecognizedException(   R   R/   (    (    R   t
   getFeaturex   s    c         C   s  |  i o t d ƒ ‚ n | t j o | |  _ nå | t j o | |  _ nË | t	 j o5 | o! |  i
 d  j o h  |  _
 qŒ qd  |  _
 n‰ | t j o | o t d ƒ ‚ qna | t j o | o t d ƒ ‚ qn9 | t j o | o t d ƒ ‚ qn t d | ƒ ‚ d  S(   Ns!   Cannot set features while parsings!   expat does not support validations/   expat does not read external parameter entitiess(   expat does not report namespace prefixess   Feature '%s' not recognized(   R   R   t   SAXNotSupportedExceptionR/   R0   t   stateR   R5   R!   R1   R"   R   R2   R3   R4   R6   (   R   R/   R9   (    (    R   t
   setFeature„   s*    
c         C   s¢   | t i j o |  i Snt | t j o |  i Sn\ | t j oN |  i o4 t	 |  i d ƒ o |  i i
 ƒ  SqŠ t d ƒ ‚ qŽ t d ƒ ‚ n t d | ƒ ‚ d  S(   Nt   GetInputContexts=   This version of expat does not support getting the XML strings.   XML string cannot be returned when not parsings   Property '%s' not recognized(   R/   R-   t   property_lexical_handlerR   R   t   property_interning_dictR"   t   property_xml_stringR   t   hasattrR;   R6   R8   (   R   R/   (    (    R   t   getProperty¢   s    
c         C   s„   | t i j o% | |  _ |  i o |  i ƒ  q€ nL | t j o | |  _	 n2 | t
 j o t d | ƒ ‚ n t d | ƒ ‚ d  S(   Ns   Property '%s' cannot be sets   Property '%s' not recognized(   R/   R-   R<   t   valueR   R   R   t   _reset_lex_handler_propR=   R"   R>   R8   R6   (   R   R/   RA   (    (    R   t   setProperty´   s    	
c         C   s’   |  i p$ |  i ƒ  d |  _ |  i i ƒ  n y |  i i | | ƒ WnF t	 i
 j
 o7 } t t	 i | i ƒ | |  ƒ } |  i i | ƒ n Xd  S(   Ni   (   R   R   R&   R'   t   startDocumentR   t   Parset   datat   isFinalt   expatt   errort   et   SAXParseExceptiont   ErrorStringt   codet   exct   _err_handlert
   fatalError(   R   RF   RG   RJ   RN   (    (    R   t   feedÄ   s    

	c         C   sH   |  i o d  Sn |  i d d d ƒ|  i i ƒ  d |  _ d  |  _ d  S(   Nt    RG   i   i    (   R   R    RQ   R'   t   endDocumentR   R   R   (   R   (    (    R   t   closeÕ   s    
	c         C   s(   |  i i |  i _ |  i i |  i _ d  S(   N(   R   R'   t   processingInstructionR   t   ProcessingInstructionHandlert
   characterst   CharacterDataHandler(   R   (    (    R   R.   ß   s    c         C   s   |  i } |  i } | d  j o1 d  | _ d  | _ d  | _ d  | _	 d  | _
 n= | i | _ | i | _ | i | _ |  i | _	 | i | _
 d  S(   N(   R   R   t   lexR   R   R   t   CommentHandlert   StartCdataSectionHandlert   EndCdataSectionHandlert   StartDoctypeDeclHandlert   EndDoctypeDeclHandlert   commentt
   startCDATAt   endCDATAt   start_doctype_declt   endDTD(   R   RY   R   (    (    R   RB   ä   s    						c         C   sT  |  i oL t i d  d d |  i ƒ|  _ d |  i _ |  i |  i _	 |  i
 |  i _ n7 t i d |  i ƒ |  _ |  i |  i _	 |  i |  i _ |  i ƒ  |  i |  i _ |  i |  i _ |  i |  i _ |  i |  i _ d  |  _ |  i o |  i ƒ  n |  i |  i _ y |  i |  i _ Wn t j
 o n X|  i i t i  ƒ d |  _! g  |  _" d  S(   Nt    t   interni   i    (#   R   R   RH   R   R   R"   R   t   namespace_prefixest   start_element_nst   StartElementHandlert   end_element_nst   EndElementHandlert   start_elementt   end_elementR.   t   unparsed_entity_declt   UnparsedEntityDeclHandlert   notation_declt   NotationDeclHandlert   start_namespace_declt   StartNamespaceDeclHandlert   end_namespace_declt   EndNamespaceDeclHandlert   _decl_handler_propR   RB   t   external_entity_reft   ExternalEntityRefHandlert   skipped_entity_handlert   SkippedEntityHandlert   AttributeErrort   SetParamEntityParsingt*   XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONER   R    (   R   (    (    R   R&   ô   s2    

	
	c         C   s"   |  i d  j o d  Sn |  i i S(   N(   R   R   R   R   (   R   (    (    R   R     s    c         C   s"   |  i d  j o d Sn |  i i S(   Ni   (   R   R   R   R   (   R   (    (    R   R     s    c         C   s   |  i i ƒ  S(   N(   R   R   R   (   R   (    (    R   R   $  s    c         C   s   |  i i ƒ  S(   N(   R   R   R   (   R   (    (    R   R   '  s    c         C   s   |  i i | t | ƒ ƒ d  S(   N(   R   R'   t   startElementR/   t   AttributesImplt   attrs(   R   R/   R   (    (    R   Rk   +  s    c         C   s   |  i i | ƒ d  S(   N(   R   R'   t
   endElementR/   (   R   R/   (    (    R   Rl   .  s    c         C   sT  | i ƒ  }
 t |
 ƒ d j o d  | f }
 n8 t |
 ƒ d j o |
 d |
 d f }
 n t |
 ƒ }
 h  }	 h  } x¼ | i	 ƒ  D]® \ } } | i ƒ  } t | ƒ } | d j o | } d  | f } nT | d j o0 d | d | d f } | d | d f } n | d } t | ƒ } | |	 | <| | | <q W|  i i |
 d  t |	 | ƒ ƒ d  S(   Ni   i   i    s   %s:%si   (   R/   t   splitt   pairt   lenR   t   tuplet   newattrst   qnamesR   t   itemst   anameRA   t   partst   lengtht   qnamet   apairR   R'   t   startElementNSt   AttributesNSImpl(   R   R/   R   RA   R†   R‹   RŠ   R‰   RŒ   R…   R‚   Rˆ   (    (    R   Rg   1  s0     

c         C   s}   | i ƒ  } t | ƒ d j o d  | f } n8 t | ƒ d j o | d | d f } n t | ƒ } |  i i | d  ƒ d  S(   Ni   i   i    (	   R/   R   R‚   Rƒ   R   R„   R   R'   t   endElementNS(   R   R/   R‚   (    (    R   Ri   S  s    c         C   s   |  i i | | ƒ d  S(   N(   R   R'   RU   t   targetRF   (   R   R   RF   (    (    R   t   processing_instruction_  s    c         C   s   |  i i | ƒ d  S(   N(   R   R'   RW   RF   (   R   RF   (    (    R   t   character_datac  s    c         C   s   |  i i | | ƒ d  S(   N(   R   R'   t   startPrefixMappingt   prefixt   uri(   R   R”   R•   (    (    R   Rq   f  s    c         C   s   |  i i | ƒ d  S(   N(   R   R'   t   endPrefixMappingR”   (   R   R”   (    (    R   Rs   i  s    c         C   s   |  i i | | | ƒ d  S(   N(   R   R   t   startDTDR/   t   pubidt   sysid(   R   R/   R™   R˜   t   has_internal_subset(    (    R   Rb   l  s    c         C   s   |  i i | | | | ƒ d  S(   N(   R   t   _dtd_handlert   unparsedEntityDeclR/   R˜   R™   t   notation_name(   R   R/   t   baseR™   R˜   R   (    (    R   Rm   o  s    c         C   s   |  i i | | | ƒ d  S(   N(   R   R›   t   notationDeclR/   R˜   R™   (   R   R/   Rž   R™   R˜   (    (    R   Ro   r  s    c         C   sÏ   |  i p d Sn |  i i | | ƒ } t i | |  i	 i
 ƒ  p d ƒ } |  i i |  i |  i	 f ƒ |  i i | ƒ |  _ | |  _	 y t i i |  | ƒ Wn d Sn X|  i d \ |  _ |  _	 |  i d =d S(   Ni   RR   i    iÿÿÿÿ(   R   R!   t   _ent_handlert   resolveEntityR˜   R™   R%   R#   R$   R   R   R    t   appendR   t   ExternalEntityParserCreatet   contextR   R   R)   (   R   R¤   Rž   R™   R˜   R%   (    (    R   Rv   u  s    
		
c         C   s)   | o d | } n |  i i | ƒ d  S(   Nt   %(   t   is_peR/   R   R'   t   skippedEntity(   R   R/   R¦   (    (    R   Rx   ‹  s    (!   R   R   R   R
   R)   R+   R,   R7   R:   R@   RC   RQ   RT   R.   RB   R&   R   R   R   R   Rk   Rl   Rg   Ri   R‘   R’   Rq   Rs   Rb   Rm   Ro   Rv   Rx   (    (    (    R   R   T   s>    									
			&							"									c          O   s   t  |  | Ž  S(   N(   R   t   argst   kwargs(   R¨   R©   (    (    R   t   create_parser“  s    t   __main__s   ../../../hamlet.xml(,   R   t   versiont   xml.sax._exceptionst   xml.sax.handlerR2   R0   R4   R5   R3   R1   R>   R=   t   syst   platformt   SAXReaderNotAvailableR   t   xml.parsersRH   t   ImportErrorR?   t   xml.saxR   R#   R-   R~   RŽ   t   _weakrefR   t   weakreft   proxyt   LocatorR   R   R   Rª   R   t   xmlt   pR,   t   saxt   XMLGeneratort   setErrorHandlert   ErrorHandlerR)   (   R¬   RH   R0   RŽ   R¶   R1   R-   R~   R4   R2   R¹   Rª   R¯   R3   R   R   R#   R=   Rµ   R   R   R>   Rº   R5   (    (    R   t   ?   sJ   					$ÿ @			