;
Òâ"Ic               @   s)  d  Z  d Z d d l Td d l m Z m Z d d l m Z d d l m Z m Z d d l m	 Z	 d d l m
 Z
 m Z d d	 l Z e j d	 d
 … d k o e d e ƒ ‚ n [ y d d l m Z Wn# e k
 o e d e ƒ ‚ Yn& Xe e d ƒ o e d e ƒ ‚ n d d l m Z m Z m Z e j Z e j Z y d d	 l Z Wn e k
 o d „  Z Yn Xd d	 l Z e j Z [ [ Gd „  d e j ƒ Z Gd „  d e j  e j ƒ Z! d „  Z" e# d k oR d d	 l Z$ e" ƒ  Z% e% j& e$ j' j( ƒ  ƒ e% j) e$ j' j* ƒ  ƒ e% j+ d ƒ n d	 S(   u]   
SAX driver for the pyexpat C module.  This driver works with
pyexpat.__version__ == '2.22'.
u   0.20i    (   u   *(   u   feature_validationu   feature_namespaces(   u   feature_namespace_prefixes(   u   feature_external_gesu   feature_external_pes(   u   feature_string_interning(   u   property_xml_stringu   property_interning_dictNi   u   javau   expat not available in Java(   u   expatu   expat not supportedu   ParserCreate(   u	   xmlreaderu   saxutilsu   handlerc             C   s   |  S(   N(    (   u   o(    (    u0   /mit/python/lib/python3.0/xml/sax/expatreader.pyu   _mkproxy'   s    c             B   sA   |  Ee  Z d  Z d „  Z d „  Z d „  Z d „  Z d „  Z d S(   u¼   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(   u   _mkproxyu   _ref(   u   selfu   parser(    (    u0   /mit/python/lib/python3.0/xml/sax/expatreader.pyu   __init__6   s    c             C   s(   |  j  } | j d  k o d  S| j j S(   N(   u   _refu   _parseru   Noneu   ErrorColumnNumber(   u   selfu   parser(    (    u0   /mit/python/lib/python3.0/xml/sax/expatreader.pyu   getColumnNumber9   s    	c             C   s(   |  j  } | j d  k o d S| j j S(   Ni   (   u   _refu   _parseru   Noneu   ErrorLineNumber(   u   selfu   parser(    (    u0   /mit/python/lib/python3.0/xml/sax/expatreader.pyu   getLineNumber?   s    	c             C   s(   |  j  } | d  k o d  S| j j ƒ  S(   N(   u   _refu   Noneu   _sourceu   getPublicId(   u   selfu   parser(    (    u0   /mit/python/lib/python3.0/xml/sax/expatreader.pyu   getPublicIdE   s    	c             C   s(   |  j  } | d  k o d  S| j j ƒ  S(   N(   u   _refu   Noneu   _sourceu   getSystemId(   u   selfu   parser(    (    u0   /mit/python/lib/python3.0/xml/sax/expatreader.pyu   getSystemIdK   s    	N(   u   __name__u
   __module__u   __doc__u   __init__u   getColumnNumberu   getLineNumberu   getPublicIdu   getSystemId(   u
   __locals__(    (    u0   /mit/python/lib/python3.0/xml/sax/expatreader.pyu   ExpatLocator0   s   
				u   ExpatLocatorc             B   s+  |  Ee  Z d  Z 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  d# S(&   u$   SAX driver for the pyexpat C module.i    i   i   i   c             C   se   t  j j |  | ƒ t  j ƒ  |  _ d  |  _ | |  _ d  |  _ d |  _	 g  |  _
 d |  _ d  |  _ d  S(   Ni    i   (   u	   xmlreaderu   IncrementalParseru   __init__u   InputSourceu   _sourceu   Noneu   _parseru   _namespacesu   _lex_handler_propu   _parsingu   _entity_stacku   _external_gesu
   _interning(   u   selfu   namespaceHandlingu   bufsize(    (    u0   /mit/python/lib/python3.0/xml/sax/expatreader.pyu   __init__W   s    						c             C   sO   t  j | ƒ } | |  _ |  j ƒ  |  j j t |  ƒ ƒ t j j	 |  | ƒ d S(   u3   Parse an XML document from a URL or an InputSource.N(
   u   saxutilsu   prepare_input_sourceu   _sourceu   resetu   _cont_handleru   setDocumentLocatoru   ExpatLocatoru	   xmlreaderu   IncrementalParseru   parse(   u   selfu   source(    (    u0   /mit/python/lib/python3.0/xml/sax/expatreader.pyu   parsed   s
    	
c             C   s1   | j  ƒ  d  k	 o |  j j | j  ƒ  ƒ n d  S(   N(   u   getSystemIdu   Noneu   _parseru   SetBase(   u   selfu   source(    (    u0   /mit/python/lib/python3.0/xml/sax/expatreader.pyu   prepareParserm   s    c             C   s/   t  j j |  | ƒ |  j o |  j ƒ  n d  S(   N(   u	   xmlreaderu   IncrementalParseru   setContentHandleru   _parsingu   _reset_cont_handler(   u   selfu   handler(    (    u0   /mit/python/lib/python3.0/xml/sax/expatreader.pyu   setContentHandlers   s    
c             C   st   | t  k o |  j S| t k o |  j d  k	 S| t t t f k o d S| t k o |  j	 St
 d | ƒ ‚ d  S(   Ni    u   Feature '%s' not recognized(   u   feature_namespacesu   _namespacesu   feature_string_interningu
   _interningu   Noneu   feature_validationu   feature_external_pesu   feature_namespace_prefixesu   feature_external_gesu   _external_gesu   SAXNotRecognizedException(   u   selfu   name(    (    u0   /mit/python/lib/python3.0/xml/sax/expatreader.pyu
   getFeaturex   s    	c             C   s  |  j  o t d ƒ ‚ n | t k o | |  _ nå | t k o | |  _ nË | t k o5 | o! |  j d  k o i  |  _ qŒ qd  |  _ n‰ | t	 k o | o t d ƒ ‚ qna | t
 k o | o t d ƒ ‚ qn9 | t k o | o t d ƒ ‚ qn t d | ƒ ‚ d  S(   Nu!   Cannot set features while parsingu!   expat does not support validationu/   expat does not read external parameter entitiesu(   expat does not report namespace prefixesu   Feature '%s' not recognized(   u   _parsingu   SAXNotSupportedExceptionu   feature_namespacesu   _namespacesu   feature_external_gesu   _external_gesu   feature_string_interningu
   _interningu   Noneu   feature_validationu   feature_external_pesu   feature_namespace_prefixesu   SAXNotRecognizedException(   u   selfu   nameu   state(    (    u0   /mit/python/lib/python3.0/xml/sax/expatreader.pyu
   setFeature„   s2    
c             C   s™   | t  j k o |  j S| t k o |  j S| t k oK |  j o1 t |  j d ƒ o |  j j ƒ  St	 d ƒ ‚ q… t
 d ƒ ‚ n t	 d | ƒ ‚ d  S(   Nu   GetInputContextu=   This version of expat does not support getting the XML stringu.   XML string cannot be returned when not parsingu   Property '%s' not recognized(   u   handleru   property_lexical_handleru   _lex_handler_propu   property_interning_dictu
   _interningu   property_xml_stringu   _parseru   hasattru   GetInputContextu   SAXNotRecognizedExceptionu   SAXNotSupportedException(   u   selfu   name(    (    u0   /mit/python/lib/python3.0/xml/sax/expatreader.pyu   getProperty¢   s    
c             C   s„   | t  j k o% | |  _ |  j o |  j ƒ  q€ nL | t k o | |  _ n2 | t k o t d | ƒ ‚ n t	 d | ƒ ‚ d  S(   Nu   Property '%s' cannot be setu   Property '%s' not recognized(
   u   handleru   property_lexical_handleru   _lex_handler_propu   _parsingu   _reset_lex_handler_propu   property_interning_dictu
   _interningu   property_xml_stringu   SAXNotSupportedExceptionu   SAXNotRecognizedException(   u   selfu   nameu   value(    (    u0   /mit/python/lib/python3.0/xml/sax/expatreader.pyu   setProperty´   s    	
c             C   s¤   |  j  p$ |  j ƒ  d |  _  |  j j ƒ  n y |  j j | | ƒ WnX t j k
 oI } z3 t t j	 | j
 ƒ | |  ƒ } |  j j | ƒ WYd  d  } ~ Xn Xd  S(   Ni   (   u   _parsingu   resetu   _cont_handleru   startDocumentu   _parseru   Parseu   expatu   erroru   SAXParseExceptionu   ErrorStringu   codeu   _err_handleru
   fatalError(   u   selfu   datau   isFinalu   eu   exc(    (    u0   /mit/python/lib/python3.0/xml/sax/expatreader.pyu   feedÄ   s    

	c             C   sE   |  j  o d  S|  j d d d ƒ|  j j ƒ  d |  _ d  |  _ d  S(   Nu    u   isFinali   i    (   u   _entity_stacku   feedu   _cont_handleru   endDocumentu   _parsingu   Noneu   _parser(   u   self(    (    u0   /mit/python/lib/python3.0/xml/sax/expatreader.pyu   closeÕ   s    
	c             C   s(   |  j  j |  j _ |  j  j |  j _ d  S(   N(   u   _cont_handleru   processingInstructionu   _parseru   ProcessingInstructionHandleru
   charactersu   CharacterDataHandler(   u   self(    (    u0   /mit/python/lib/python3.0/xml/sax/expatreader.pyu   _reset_cont_handlerß   s    c             C   s   |  j  } |  j } | d  k o1 d  | _ d  | _ d  | _ d  | _ d  | _ n= | j | _ | j	 | _ | j
 | _ |  j | _ | j | _ d  S(   N(   u   _lex_handler_propu   _parseru   Noneu   CommentHandleru   StartCdataSectionHandleru   EndCdataSectionHandleru   StartDoctypeDeclHandleru   EndDoctypeDeclHandleru   commentu
   startCDATAu   endCDATAu   start_doctype_declu   endDTD(   u   selfu   lexu   parser(    (    u0   /mit/python/lib/python3.0/xml/sax/expatreader.pyu   _reset_lex_handler_propä   s    						c             C   sj  |  j  oU t j |  j j ƒ  d d |  j ƒ|  _ d |  j _ |  j |  j _	 |  j
 |  j _ nC t j |  j j ƒ  d |  j ƒ|  _ |  j |  j _	 |  j |  j _ |  j ƒ  |  j |  j _ |  j |  j _ |  j |  j _ |  j |  j _ d  |  _ |  j o |  j ƒ  n |  j |  j _ y |  j |  j _ Wn t k
 o Yn X|  j j  t j! ƒ d |  _" g  |  _# d  S(   Nu    u   interni   i    ($   u   _namespacesu   expatu   ParserCreateu   _sourceu   getEncodingu
   _interningu   _parseru   namespace_prefixesu   start_element_nsu   StartElementHandleru   end_element_nsu   EndElementHandleru   start_elementu   end_elementu   _reset_cont_handleru   unparsed_entity_declu   UnparsedEntityDeclHandleru   notation_declu   NotationDeclHandleru   start_namespace_declu   StartNamespaceDeclHandleru   end_namespace_declu   EndNamespaceDeclHandleru   Noneu   _decl_handler_propu   _lex_handler_propu   _reset_lex_handler_propu   external_entity_refu   ExternalEntityRefHandleru   skipped_entity_handleru   SkippedEntityHandleru   AttributeErroru   SetParamEntityParsingu*   XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONEu   _parsingu   _entity_stack(   u   self(    (    u0   /mit/python/lib/python3.0/xml/sax/expatreader.pyu   resetô   s6    

	
	
	c             C   s   |  j  d  k o d  S|  j  j S(   N(   u   _parseru   Noneu   ErrorColumnNumber(   u   self(    (    u0   /mit/python/lib/python3.0/xml/sax/expatreader.pyu   getColumnNumber  s    c             C   s   |  j  d  k o d S|  j  j S(   Ni   (   u   _parseru   Noneu   ErrorLineNumber(   u   self(    (    u0   /mit/python/lib/python3.0/xml/sax/expatreader.pyu   getLineNumber   s    c             C   s   |  j  j ƒ  S(   N(   u   _sourceu   getPublicId(   u   self(    (    u0   /mit/python/lib/python3.0/xml/sax/expatreader.pyu   getPublicId%  s    c             C   s   |  j  j ƒ  S(   N(   u   _sourceu   getSystemId(   u   self(    (    u0   /mit/python/lib/python3.0/xml/sax/expatreader.pyu   getSystemId(  s    c             C   s   |  j  j | t | ƒ ƒ d  S(   N(   u   _cont_handleru   startElementu   AttributesImpl(   u   selfu   nameu   attrs(    (    u0   /mit/python/lib/python3.0/xml/sax/expatreader.pyu   start_element,  s    c             C   s   |  j  j | ƒ d  S(   N(   u   _cont_handleru
   endElement(   u   selfu   name(    (    u0   /mit/python/lib/python3.0/xml/sax/expatreader.pyu   end_element/  s    c             C   sT  | j  ƒ  } t | ƒ d k o d  | f } n8 t | ƒ d k o | d | d f } n t | ƒ } i  } i  } x¼ | j ƒ  D]® \ } } | j  ƒ  } t | ƒ }	 |	 d k o | }
 d  | f } nT |	 d k o0 d | d | d f }
 | d | d f } n | d }
 t | ƒ } | | | <|
 | | <q W|  j j | d  t | | ƒ ƒ d  S(   Ni   i   i    u   %s:%si   (   u   splitu   lenu   Noneu   tupleu   itemsu   _cont_handleru   startElementNSu   AttributesNSImpl(   u   selfu   nameu   attrsu   pairu   newattrsu   qnamesu   anameu   valueu   partsu   lengthu   qnameu   apair(    (    u0   /mit/python/lib/python3.0/xml/sax/expatreader.pyu   start_element_ns2  s0     

c             C   s}   | j  ƒ  } t | ƒ d k o d  | f } n8 t | ƒ d k o | d | d f } n t | ƒ } |  j j | d  ƒ d  S(   Ni   i   i    (   u   splitu   lenu   Noneu   tupleu   _cont_handleru   endElementNS(   u   selfu   nameu   pair(    (    u0   /mit/python/lib/python3.0/xml/sax/expatreader.pyu   end_element_nsT  s    c             C   s   |  j  j | | ƒ d  S(   N(   u   _cont_handleru   processingInstruction(   u   selfu   targetu   data(    (    u0   /mit/python/lib/python3.0/xml/sax/expatreader.pyu   processing_instruction`  s    c             C   s   |  j  j | ƒ d  S(   N(   u   _cont_handleru
   characters(   u   selfu   data(    (    u0   /mit/python/lib/python3.0/xml/sax/expatreader.pyu   character_datad  s    c             C   s   |  j  j | | ƒ d  S(   N(   u   _cont_handleru   startPrefixMapping(   u   selfu   prefixu   uri(    (    u0   /mit/python/lib/python3.0/xml/sax/expatreader.pyu   start_namespace_declg  s    c             C   s   |  j  j | ƒ d  S(   N(   u   _cont_handleru   endPrefixMapping(   u   selfu   prefix(    (    u0   /mit/python/lib/python3.0/xml/sax/expatreader.pyu   end_namespace_declj  s    c             C   s   |  j  j | | | ƒ d  S(   N(   u   _lex_handler_propu   startDTD(   u   selfu   nameu   sysidu   pubidu   has_internal_subset(    (    u0   /mit/python/lib/python3.0/xml/sax/expatreader.pyu   start_doctype_declm  s    c             C   s   |  j  j | | | | ƒ d  S(   N(   u   _dtd_handleru   unparsedEntityDecl(   u   selfu   nameu   baseu   sysidu   pubidu   notation_name(    (    u0   /mit/python/lib/python3.0/xml/sax/expatreader.pyu   unparsed_entity_declp  s    c             C   s   |  j  j | | | ƒ d  S(   N(   u   _dtd_handleru   notationDecl(   u   selfu   nameu   baseu   sysidu   pubid(    (    u0   /mit/python/lib/python3.0/xml/sax/expatreader.pyu   notation_decls  s    c          	   C   sÍ   |  j  p d S|  j j | | ƒ } t j | |  j j ƒ  p d ƒ } |  j j |  j	 |  j f ƒ |  j	 j
 | ƒ |  _	 | |  _ y t j j |  | ƒ Wn d SYn X|  j d \ |  _	 |  _ |  j d =d S(   Ni   u    i    iÿÿÿÿ(   u   _external_gesu   _ent_handleru   resolveEntityu   saxutilsu   prepare_input_sourceu   _sourceu   getSystemIdu   _entity_stacku   appendu   _parseru   ExternalEntityParserCreateu	   xmlreaderu   IncrementalParseru   parse(   u   selfu   contextu   baseu   sysidu   pubidu   source(    (    u0   /mit/python/lib/python3.0/xml/sax/expatreader.pyu   external_entity_refv  s     
				
c             C   s)   | o d | } n |  j  j | ƒ d  S(   Nu   %(   u   _cont_handleru   skippedEntity(   u   selfu   nameu   is_pe(    (    u0   /mit/python/lib/python3.0/xml/sax/expatreader.pyu   skipped_entity_handlerŒ  s    Ni   iìÿ  (!   u   __name__u
   __module__u   __doc__u   __init__u   parseu   prepareParseru   setContentHandleru
   getFeatureu
   setFeatureu   getPropertyu   setPropertyu   feedu   closeu   _reset_cont_handleru   _reset_lex_handler_propu   resetu   getColumnNumberu   getLineNumberu   getPublicIdu   getSystemIdu   start_elementu   end_elementu   start_element_nsu   end_element_nsu   processing_instructionu   character_datau   start_namespace_declu   end_namespace_declu   start_doctype_declu   unparsed_entity_declu   notation_declu   external_entity_refu   skipped_entity_handler(   u
   __locals__(    (    u0   /mit/python/lib/python3.0/xml/sax/expatreader.pyu   ExpatParserT   s>   
									
			'							"									u   ExpatParserc              O   s   t  |  | Ž  S(   N(   u   ExpatParser(   u   argsu   kwargs(    (    u0   /mit/python/lib/python3.0/xml/sax/expatreader.pyu   create_parser”  s    u   __main__u   ../../../hamlet.xml(,   u   __doc__u   versionu   xml.sax._exceptionsu   xml.sax.handleru   feature_validationu   feature_namespacesu   feature_namespace_prefixesu   feature_external_gesu   feature_external_pesu   feature_string_interningu   property_xml_stringu   property_interning_dictu   sysu   platformu   SAXReaderNotAvailableu   Noneu   xml.parsersu   expatu   ImportErroru   hasattru   xml.saxu	   xmlreaderu   saxutilsu   handleru   AttributesImplu   AttributesNSImplu   _weakrefu   _mkproxyu   weakrefu   proxyu   Locatoru   ExpatLocatoru   IncrementalParseru   ExpatParseru   create_parseru   __name__u   xmlu   pu   setContentHandleru   saxu   XMLGeneratoru   setErrorHandleru   ErrorHandleru   parse(    (    (    u0   /mit/python/lib/python3.0/xml/sax/expatreader.pyu   <module>   sJ   
			$ÿ A		