<s> """<STR_LIT>""" <EOL> import handler <EOL> from _exceptions import SAXNotSupportedException , SAXNotRecognizedException <EOL> class XMLReader : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self ) : <EOL> self . _cont_handler = handler . ContentHandler ( ) <EOL> self . _dtd_handler = handler . DTDHandler ( ) <EOL> self . _ent_handler = handler . EntityResolver ( ) <EOL> self . _err_handler = handler . ErrorHandler ( ) <EOL> def parse ( self , source ) : <EOL> "<STR_LIT>" <EOL> raise NotImplementedError ( "<STR_LIT>" ) <EOL> def getContentHandler ( self ) : <EOL> "<STR_LIT>" <EOL> return self . _cont_handler <EOL> def setContentHandler ( self , handler ) : <EOL> "<STR_LIT>" <EOL> self . _cont_handler = handler <EOL> def getDTDHandler ( self ) : <EOL> "<STR_LIT>" <EOL> return self . _dtd_handler <EOL> def setDTDHandler ( self , handler ) : <EOL> "<STR_LIT>" <EOL> self . _dtd_handler = handler <EOL> def getEntityResolver ( self ) : <EOL> "<STR_LIT>" <EOL> return self . _ent_handler <EOL> def setEntityResolver ( self , resolver ) : <EOL> "<STR_LIT>" <EOL> self . _ent_handler = resolver <EOL> def getErrorHandler ( self ) : <EOL> "<STR_LIT>" <EOL> return self . _err_handler <EOL> def setErrorHandler ( self , handler ) : <EOL> "<STR_LIT>" <EOL> self . _err_handler = handler <EOL> def setLocale ( self , locale ) : <EOL> """<STR_LIT>""" <EOL> raise SAXNotSupportedException ( "<STR_LIT>" ) <EOL> def getFeature ( self , name ) : <EOL> "<STR_LIT>" <EOL> raise SAXNotRecognizedException ( "<STR_LIT>" % name ) <EOL> def setFeature ( self , name , state ) : <EOL> "<STR_LIT>" <EOL> raise SAXNotRecognizedException ( "<STR_LIT>" % name ) <EOL> def getProperty ( self , name ) : <EOL> "<STR_LIT>" <EOL> raise SAXNotRecognizedException ( "<STR_LIT>" % name ) <EOL> def setProperty ( self , name , value ) : <EOL> "<STR_LIT>" <EOL> raise SAXNotRecognizedException ( "<STR_LIT>" % name ) <EOL> class IncrementalParser ( XMLReader ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , bufsize = <NUM_LIT:2> ** <NUM_LIT:16> ) : <EOL> self . _bufsize = bufsize <EOL> XMLReader . __init__ ( self ) <EOL> def parse ( self , source ) : <EOL> import saxutils <EOL> source = saxutils . prepare_input_source ( source ) <EOL> self . prepareParser ( source ) <EOL> file = source . getByteStream ( ) <EOL> buffer = file . read ( self . _bufsize ) <EOL> while buffer != "<STR_LIT>" : <EOL> self . feed ( buffer ) <EOL> buffer = file . read ( self . _bufsize ) <EOL> self . close ( ) <EOL> def feed ( self , data ) : <EOL> """<STR_LIT>""" <EOL> raise NotImplementedError ( "<STR_LIT>" ) <EOL> def prepareParser ( self , source ) : <EOL> """<STR_LIT>""" <EOL> raise NotImplementedError ( "<STR_LIT>" ) <EOL> def close ( self ) : <EOL> """<STR_LIT>""" <EOL> raise NotImplementedError ( "<STR_LIT>" ) <EOL> def reset ( self ) : <EOL> """<STR_LIT>""" <EOL> raise NotImplementedError ( "<STR_LIT>" ) <EOL> class Locator : <EOL> """<STR_LIT>""" <EOL> def getColumnNumber ( self ) : <EOL> "<STR_LIT>" <EOL> return - <NUM_LIT:1> <EOL> def getLineNumber ( self ) : <EOL> "<STR_LIT>" <EOL> return - <NUM_LIT:1> <EOL> def getPublicId ( self ) : <EOL> "<STR_LIT>" <EOL> return None <EOL> def getSystemId ( self ) : <EOL> "<STR_LIT>" <EOL> return None <EOL> class InputSource : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , system_id = None ) : <EOL> self . __system_id = system_id <EOL> self . __public_id = None <EOL> self . __encoding = None <EOL> self . __bytefile = None <EOL> self . __charfile = None <EOL> def setPublicId ( self , public_id ) : <EOL> "<STR_LIT>" <EOL> self . __public_id = public_id <EOL> def getPublicId ( self ) : <EOL> "<STR_LIT>" <EOL> return self . __public_id <EOL> def setSystemId ( self , system_id ) : <EOL> "<STR_LIT>" <EOL> self . __system_id = system_id <EOL> def getSystemId ( self ) : <EOL> "<STR_LIT>" <EOL> return self . __system_id <EOL> def setEncoding ( self , encoding ) : <EOL> """<STR_LIT>""" <EOL> self . __encoding = encoding <EOL> def getEncoding ( self ) : <EOL> "<STR_LIT>" <EOL> return self . __encoding <EOL> def setByteStream ( self , bytefile ) : <EOL> """<STR_LIT>""" <EOL> self . __bytefile = bytefile <EOL> def getByteStream ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . __bytefile <EOL> def setCharacterStream ( self , charfile ) : <EOL> """<STR_LIT>""" <EOL> self . __charfile = charfile <EOL> def getCharacterStream ( self ) : <EOL> "<STR_LIT>" <EOL> return self . __charfile <EOL> class AttributesImpl : <EOL> def __init__ ( self , attrs ) : <EOL> """<STR_LIT>""" <EOL> self . _attrs = attrs <EOL> def getLength ( self ) : <EOL> return len ( self . _attrs ) <EOL> def getType ( self , name ) : <EOL> return "<STR_LIT>" <EOL> def getValue ( self , name ) : <EOL> return self . _attrs [ name ] <EOL> def getValueByQName ( self , name ) : <EOL> return self . _attrs [ name ] <EOL> def getNameByQName ( self , name ) : <EOL> if not name in self . _attrs : <EOL> raise KeyError , name <EOL> return name <EOL> def getQNameByName ( self , name ) : <EOL> if not name in self . _attrs : <EOL> raise KeyError , name <EOL> return name <EOL> def getNames ( self ) : <EOL> return self . _attrs . keys ( ) <EOL> def getQNames ( self ) : <EOL> return self . _attrs . keys ( ) <EOL> def __len__ ( self ) : <EOL> return len ( self . _attrs ) <EOL> def __getitem__ ( self , name ) : <EOL> return self . _attrs [ name ] <EOL> def keys ( self ) : <EOL> return self . _attrs . keys ( ) <EOL> def has_key ( self , name ) : <EOL> return name in self . _attrs <EOL> def __contains__ ( self , name ) : <EOL> return name in self . _attrs <EOL> def get ( self , name , alternative = None ) : <EOL> return self . _attrs . get ( name , alternative ) <EOL> def copy ( self ) : <EOL> return self . __class__ ( self . _attrs ) <EOL> def items ( self ) : <EOL> return self . _attrs . items ( ) <EOL> def values ( self ) : <EOL> return self . _attrs . values ( ) <EOL> class AttributesNSImpl ( AttributesImpl ) : <EOL> def __init__ ( self , attrs , qnames ) : <EOL> """<STR_LIT>""" <EOL> self . _attrs = attrs <EOL> self . _qnames = qnames <EOL> def getValueByQName ( self , name ) : <EOL> for ( nsname , qname ) in self . _qnames . items ( ) : <EOL> if qname == name : <EOL> return self . _attrs [ nsname ] <EOL> raise KeyError , name <EOL> def getNameByQName ( self , name ) : <EOL> for ( nsname , qname ) in self . _qnames . items ( ) : <EOL> if qname == name : <EOL> return nsname <EOL> raise KeyError , name <EOL> def getQNameByName ( self , name ) : <EOL> return self . _qnames [ name ] <EOL> def getQNames ( self ) : <EOL> return self . _qnames . values ( ) <EOL> def copy ( self ) : <EOL> return self . __class__ ( self . _attrs , self . _qnames ) <EOL> def _test ( ) : <EOL> XMLReader ( ) <EOL> IncrementalParser ( ) <EOL> Locator ( ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> _test ( ) </s>
