<s> __all__ = [ <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> ] <EOL> import string , sys , re <EOL> class _SimpleElementPath : <EOL> def find ( self , element , tag ) : <EOL> for elem in element : <EOL> if elem . tag == tag : <EOL> return elem <EOL> return None <EOL> def findtext ( self , element , tag , default = None ) : <EOL> for elem in element : <EOL> if elem . tag == tag : <EOL> return elem . text or "<STR_LIT>" <EOL> return default <EOL> def findall ( self , element , tag ) : <EOL> if tag [ : <NUM_LIT:3> ] == "<STR_LIT>" : <EOL> return element . getiterator ( tag [ <NUM_LIT:3> : ] ) <EOL> result = [ ] <EOL> for elem in element : <EOL> if elem . tag == tag : <EOL> result . append ( elem ) <EOL> return result <EOL> try : <EOL> import ElementPath <EOL> except ImportError : <EOL> ElementPath = _SimpleElementPath ( ) <EOL> VERSION = "<STR_LIT>" <EOL> class _ElementInterface : <EOL> tag = None <EOL> attrib = None <EOL> text = None <EOL> tail = None <EOL> def __init__ ( self , tag , attrib ) : <EOL> self . tag = tag <EOL> self . attrib = attrib <EOL> self . _children = [ ] <EOL> def __repr__ ( self ) : <EOL> return "<STR_LIT>" % ( self . tag , id ( self ) ) <EOL> def makeelement ( self , tag , attrib ) : <EOL> return Element ( tag , attrib ) <EOL> def __len__ ( self ) : <EOL> return len ( self . _children ) <EOL> def __getitem__ ( self , index ) : <EOL> return self . _children [ index ] <EOL> def __setitem__ ( self , index , element ) : <EOL> assert iselement ( element ) <EOL> self . _children [ index ] = element <EOL> def __delitem__ ( self , index ) : <EOL> del self . _children [ index ] <EOL> def __getslice__ ( self , start , stop ) : <EOL> return self . _children [ start : stop ] <EOL> def __setslice__ ( self , start , stop , elements ) : <EOL> for element in elements : <EOL> assert iselement ( element ) <EOL> self . _children [ start : stop ] = list ( elements ) <EOL> def __delslice__ ( self , start , stop ) : <EOL> del self . _children [ start : stop ] <EOL> def append ( self , element ) : <EOL> assert iselement ( element ) <EOL> self . _children . append ( element ) <EOL> def insert ( self , index , element ) : <EOL> assert iselement ( element ) <EOL> self . _children . insert ( index , element ) <EOL> def remove ( self , element ) : <EOL> assert iselement ( element ) <EOL> self . _children . remove ( element ) <EOL> def getchildren ( self ) : <EOL> return self . _children <EOL> def find ( self , path ) : <EOL> return ElementPath . find ( self , path ) <EOL> def findtext ( self , path , default = None ) : <EOL> return ElementPath . findtext ( self , path , default ) <EOL> def findall ( self , path ) : <EOL> return ElementPath . findall ( self , path ) <EOL> def clear ( self ) : <EOL> self . attrib . clear ( ) <EOL> self . _children = [ ] <EOL> self . text = self . tail = None <EOL> def get ( self , key , default = None ) : <EOL> return self . attrib . get ( key , default ) <EOL> def set ( self , key , value ) : <EOL> self . attrib [ key ] = value <EOL> def keys ( self ) : <EOL> return self . attrib . keys ( ) <EOL> def items ( self ) : <EOL> return self . attrib . items ( ) <EOL> def getiterator ( self , tag = None ) : <EOL> nodes = [ ] <EOL> if tag == "<STR_LIT:*>" : <EOL> tag = None <EOL> if tag is None or self . tag == tag : <EOL> nodes . append ( self ) <EOL> for node in self . _children : <EOL> nodes . extend ( node . getiterator ( tag ) ) <EOL> return nodes <EOL> _Element = _ElementInterface <EOL> def Element ( tag , attrib = { } , ** extra ) : <EOL> attrib = attrib . copy ( ) <EOL> attrib . update ( extra ) <EOL> return _ElementInterface ( tag , attrib ) <EOL> def SubElement ( parent , tag , attrib = { } , ** extra ) : <EOL> attrib = attrib . copy ( ) <EOL> attrib . update ( extra ) <EOL> element = parent . makeelement ( tag , attrib ) <EOL> parent . append ( element ) <EOL> return element <EOL> def Comment ( text = None ) : <EOL> element = Element ( Comment ) <EOL> element . text = text <EOL> return element <EOL> def ProcessingInstruction ( target , text = None ) : <EOL> element = Element ( ProcessingInstruction ) <EOL> element . text = target <EOL> if text : <EOL> element . text = element . text + "<STR_LIT:U+0020>" + text <EOL> return element <EOL> PI = ProcessingInstruction <EOL> class QName : <EOL> def __init__ ( self , text_or_uri , tag = None ) : <EOL> if tag : <EOL> text_or_uri = "<STR_LIT>" % ( text_or_uri , tag ) <EOL> self . text = text_or_uri <EOL> def __str__ ( self ) : <EOL> return self . text <EOL> def __hash__ ( self ) : <EOL> return hash ( self . text ) <EOL> def __cmp__ ( self , other ) : <EOL> if isinstance ( other , QName ) : <EOL> return cmp ( self . text , other . text ) <EOL> return cmp ( self . text , other ) <EOL> class ElementTree : <EOL> def __init__ ( self , element = None , file = None ) : <EOL> assert element is None or iselement ( element ) <EOL> self . _root = element <EOL> if file : <EOL> self . parse ( file ) <EOL> def getroot ( self ) : <EOL> return self . _root <EOL> def _setroot ( self , element ) : <EOL> assert iselement ( element ) <EOL> self . _root = element <EOL> def parse ( self , source , parser = None ) : <EOL> if not hasattr ( source , "<STR_LIT>" ) : <EOL> source = open ( source , "<STR_LIT:rb>" ) <EOL> if not parser : <EOL> parser = XMLTreeBuilder ( ) <EOL> while <NUM_LIT:1> : <EOL> data = source . read ( <NUM_LIT> ) <EOL> if not data : <EOL> break <EOL> parser . feed ( data ) <EOL> self . _root = parser . close ( ) <EOL> return self . _root <EOL> def getiterator ( self , tag = None ) : <EOL> assert self . _root is not None <EOL> return self . _root . getiterator ( tag ) <EOL> def find ( self , path ) : <EOL> assert self . _root is not None <EOL> if path [ : <NUM_LIT:1> ] == "<STR_LIT:/>" : <EOL> path = "<STR_LIT:.>" + path <EOL> return self . _root . find ( path ) <EOL> def findtext ( self , path , default = None ) : <EOL> assert self . _root is not None <EOL> if path [ : <NUM_LIT:1> ] == "<STR_LIT:/>" : <EOL> path = "<STR_LIT:.>" + path <EOL> return self . _root . findtext ( path , default ) <EOL> def findall ( self , path ) : <EOL> assert self . _root is not None <EOL> if path [ : <NUM_LIT:1> ] == "<STR_LIT:/>" : <EOL> path = "<STR_LIT:.>" + path <EOL> return self . _root . findall ( path ) <EOL> def write ( self , file , encoding = "<STR_LIT>" ) : <EOL> assert self . _root is not None <EOL> if not hasattr ( file , "<STR_LIT>" ) : <EOL> file = open ( file , "<STR_LIT:wb>" ) <EOL> if not encoding : <EOL> encoding = "<STR_LIT>" <EOL> elif encoding != "<STR_LIT:utf-8>" and encoding != "<STR_LIT>" : <EOL> file . write ( "<STR_LIT>" % encoding ) <EOL> self . _write ( file , self . _root , encoding , { } ) <EOL> def _write ( self , file , node , encoding , namespaces ) : <EOL> tag = node . tag <EOL> if tag is Comment : <EOL> file . write ( "<STR_LIT>" % _escape_cdata ( node . text , encoding ) ) <EOL> elif tag is ProcessingInstruction : <EOL> file . write ( "<STR_LIT>" % _escape_cdata ( node . text , encoding ) ) <EOL> else : <EOL> items = node . items ( ) <EOL> xmlns_items = [ ] <EOL> try : <EOL> if isinstance ( tag , QName ) or tag [ : <NUM_LIT:1> ] == "<STR_LIT:{>" : <EOL> tag , xmlns = fixtag ( tag , namespaces ) <EOL> if xmlns : xmlns_items . append ( xmlns ) <EOL> except TypeError : <EOL> _raise_serialization_error ( tag ) <EOL> file . write ( "<STR_LIT:<>" + _encode ( tag , encoding ) ) <EOL> if items or xmlns_items : <EOL> items . sort ( ) <EOL> for k , v in items : <EOL> try : <EOL> if isinstance ( k , QName ) or k [ : <NUM_LIT:1> ] == "<STR_LIT:{>" : <EOL> k , xmlns = fixtag ( k , namespaces ) <EOL> if xmlns : xmlns_items . append ( xmlns ) <EOL> except TypeError : <EOL> _raise_serialization_error ( k ) <EOL> try : <EOL> if isinstance ( v , QName ) : <EOL> v , xmlns = fixtag ( v , namespaces ) <EOL> if xmlns : xmlns_items . append ( xmlns ) <EOL> except TypeError : <EOL> _raise_serialization_error ( v ) <EOL> file . write ( "<STR_LIT>" % ( _encode ( k , encoding ) , <EOL> _escape_attrib ( v , encoding ) ) ) <EOL> for k , v in xmlns_items : <EOL> file . write ( "<STR_LIT>" % ( _encode ( k , encoding ) , <EOL> _escape_attrib ( v , encoding ) ) ) <EOL> if node . text or len ( node ) : <EOL> file . write ( "<STR_LIT:>>" ) <EOL> if node . text : <EOL> file . write ( _escape_cdata ( node . text , encoding ) ) <EOL> for n in node : <EOL> self . _write ( file , n , encoding , namespaces ) <EOL> file . write ( "<STR_LIT>" + _encode ( tag , encoding ) + "<STR_LIT:>>" ) <EOL> else : <EOL> file . write ( "<STR_LIT>" ) <EOL> for k , v in xmlns_items : <EOL> del namespaces [ v ] <EOL> if node . tail : <EOL> file . write ( _escape_cdata ( node . tail , encoding ) ) <EOL> def iselement ( element ) : <EOL> return isinstance ( element , _ElementInterface ) or hasattr ( element , "<STR_LIT>" ) <EOL> def dump ( elem ) : <EOL> if not isinstance ( elem , ElementTree ) : <EOL> elem = ElementTree ( elem ) <EOL> elem . write ( sys . stdout ) <EOL> tail = elem . getroot ( ) . tail <EOL> if not tail or tail [ - <NUM_LIT:1> ] != "<STR_LIT:\n>" : <EOL> sys . stdout . write ( "<STR_LIT:\n>" ) <EOL> def _encode ( s , encoding ) : <EOL> try : <EOL> return s . encode ( encoding ) <EOL> except AttributeError : <EOL> return s <EOL> if sys . version [ : <NUM_LIT:3> ] == "<STR_LIT>" : <EOL> _escape = re . compile ( r"<STR_LIT>" ) <EOL> else : <EOL> _escape = re . compile ( eval ( r'<STR_LIT>' ) ) <EOL> _escape_map = { <EOL> "<STR_LIT:&>" : "<STR_LIT>" , <EOL> "<STR_LIT:<>" : "<STR_LIT>" , <EOL> "<STR_LIT:>>" : "<STR_LIT>" , <EOL> '<STR_LIT:">' : "<STR_LIT>" , <EOL> } <EOL> _namespace_map = { <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT:html>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> } <EOL> def _raise_serialization_error ( text ) : <EOL> raise TypeError ( <EOL> "<STR_LIT>" % ( text , type ( text ) . __name__ ) <EOL> ) <EOL> def _encode_entity ( text , pattern = _escape ) : <EOL> def escape_entities ( m , map = _escape_map ) : <EOL> out = [ ] <EOL> append = out . append <EOL> for char in m . group ( ) : <EOL> text = map . get ( char ) <EOL> if text is None : <EOL> text = "<STR_LIT>" % ord ( char ) <EOL> append ( text ) <EOL> return string . join ( out , "<STR_LIT>" ) <EOL> try : <EOL> return _encode ( pattern . sub ( escape_entities , text ) , "<STR_LIT:ascii>" ) <EOL> except TypeError : <EOL> _raise_serialization_error ( text ) <EOL> def _escape_cdata ( text , encoding = None , replace = string . replace ) : <EOL> try : <EOL> if encoding : <EOL> try : <EOL> text = _encode ( text , encoding ) <EOL> except UnicodeError : <EOL> return _encode_entity ( text ) <EOL> text = replace ( text , "<STR_LIT:&>" , "<STR_LIT>" ) <EOL> text = replace ( text , "<STR_LIT:<>" , "<STR_LIT>" ) <EOL> text = replace ( text , "<STR_LIT:>>" , "<STR_LIT>" ) <EOL> return text <EOL> except ( TypeError , AttributeError ) : <EOL> _raise_serialization_error ( text ) <EOL> def _escape_attrib ( text , encoding = None , replace = string . replace ) : <EOL> try : <EOL> if encoding : <EOL> try : <EOL> text = _encode ( text , encoding ) <EOL> except UnicodeError : <EOL> return _encode_entity ( text ) <EOL> text = replace ( text , "<STR_LIT:&>" , "<STR_LIT>" ) <EOL> text = replace ( text , "<STR_LIT:'>" , "<STR_LIT>" ) <EOL> text = replace ( text , "<STR_LIT>" , "<STR_LIT>" ) <EOL> text = replace ( text , "<STR_LIT:<>" , "<STR_LIT>" ) <EOL> text = replace ( text , "<STR_LIT:>>" , "<STR_LIT>" ) <EOL> return text <EOL> except ( TypeError , AttributeError ) : <EOL> _raise_serialization_error ( text ) <EOL> def fixtag ( tag , namespaces ) : <EOL> if isinstance ( tag , QName ) : <EOL> tag = tag . text <EOL> namespace_uri , tag = string . split ( tag [ <NUM_LIT:1> : ] , "<STR_LIT:}>" , <NUM_LIT:1> ) <EOL> prefix = namespaces . get ( namespace_uri ) <EOL> if prefix is None : <EOL> prefix = _namespace_map . get ( namespace_uri ) <EOL> if prefix is None : <EOL> prefix = "<STR_LIT>" % len ( namespaces ) <EOL> namespaces [ namespace_uri ] = prefix <EOL> if prefix == "<STR_LIT>" : <EOL> xmlns = None <EOL> else : <EOL> xmlns = ( "<STR_LIT>" % prefix , namespace_uri ) <EOL> else : <EOL> xmlns = None <EOL> return "<STR_LIT>" % ( prefix , tag ) , xmlns <EOL> def parse ( source , parser = None ) : <EOL> tree = ElementTree ( ) <EOL> tree . parse ( source , parser ) <EOL> return tree <EOL> class iterparse : <EOL> def __init__ ( self , source , events = None ) : <EOL> if not hasattr ( source , "<STR_LIT>" ) : <EOL> source = open ( source , "<STR_LIT:rb>" ) <EOL> self . _file = source <EOL> self . _events = [ ] <EOL> self . _index = <NUM_LIT:0> <EOL> self . root = self . _root = None <EOL> self . _parser = XMLTreeBuilder ( ) <EOL> parser = self . _parser . _parser <EOL> append = self . _events . append <EOL> if events is None : <EOL> events = [ "<STR_LIT:end>" ] <EOL> for event in events : <EOL> if event == "<STR_LIT:start>" : <EOL> try : <EOL> parser . ordered_attributes = <NUM_LIT:1> <EOL> parser . specified_attributes = <NUM_LIT:1> <EOL> def handler ( tag , attrib_in , event = event , append = append , <EOL> start = self . _parser . _start_list ) : <EOL> append ( ( event , start ( tag , attrib_in ) ) ) <EOL> parser . StartElementHandler = handler <EOL> except AttributeError : <EOL> def handler ( tag , attrib_in , event = event , append = append , <EOL> start = self . _parser . _start ) : <EOL> append ( ( event , start ( tag , attrib_in ) ) ) <EOL> parser . StartElementHandler = handler <EOL> elif event == "<STR_LIT:end>" : <EOL> def handler ( tag , event = event , append = append , <EOL> end = self . _parser . _end ) : <EOL> append ( ( event , end ( tag ) ) ) <EOL> parser . EndElementHandler = handler <EOL> elif event == "<STR_LIT>" : <EOL> def handler ( prefix , uri , event = event , append = append ) : <EOL> try : <EOL> uri = _encode ( uri , "<STR_LIT:ascii>" ) <EOL> except UnicodeError : <EOL> pass <EOL> append ( ( event , ( prefix or "<STR_LIT>" , uri ) ) ) <EOL> parser . StartNamespaceDeclHandler = handler <EOL> elif event == "<STR_LIT>" : <EOL> def handler ( prefix , event = event , append = append ) : <EOL> append ( ( event , None ) ) <EOL> parser . EndNamespaceDeclHandler = handler <EOL> def next ( self ) : <EOL> while <NUM_LIT:1> : <EOL> try : <EOL> item = self . _events [ self . _index ] <EOL> except IndexError : <EOL> if self . _parser is None : <EOL> self . root = self . _root <EOL> try : <EOL> raise StopIteration <EOL> except NameError : <EOL> raise IndexError <EOL> del self . _events [ : ] <EOL> self . _index = <NUM_LIT:0> <EOL> data = self . _file . read ( <NUM_LIT> ) <EOL> if data : <EOL> self . _parser . feed ( data ) <EOL> else : <EOL> self . _root = self . _parser . close ( ) <EOL> self . _parser = None <EOL> else : <EOL> self . _index = self . _index + <NUM_LIT:1> <EOL> return item <EOL> try : <EOL> iter <EOL> def __iter__ ( self ) : <EOL> return self <EOL> except NameError : <EOL> def __getitem__ ( self , index ) : <EOL> return self . next ( ) <EOL> def XML ( text ) : <EOL> parser = XMLTreeBuilder ( ) <EOL> parser . feed ( text ) <EOL> return parser . close ( ) <EOL> def XMLID ( text ) : <EOL> parser = XMLTreeBuilder ( ) <EOL> parser . feed ( text ) <EOL> tree = parser . close ( ) <EOL> ids = { } <EOL> for elem in tree . getiterator ( ) : <EOL> id = elem . get ( "<STR_LIT:id>" ) <EOL> if id : <EOL> ids [ id ] = elem <EOL> return tree , ids <EOL> fromstring = XML <EOL> def tostring ( element , encoding = None ) : <EOL> class dummy : <EOL> pass <EOL> data = [ ] <EOL> file = dummy ( ) <EOL> file . write = data . append <EOL> ElementTree ( element ) . write ( file , encoding ) <EOL> return string . join ( data , "<STR_LIT>" ) <EOL> class TreeBuilder : <EOL> def __init__ ( self , element_factory = None ) : <EOL> self . _data = [ ] <EOL> self . _elem = [ ] <EOL> self . _last = None <EOL> self . _tail = None <EOL> if element_factory is None : <EOL> element_factory = _ElementInterface <EOL> self . _factory = element_factory <EOL> def close ( self ) : <EOL> assert len ( self . _elem ) == <NUM_LIT:0> , "<STR_LIT>" <EOL> assert self . _last != None , "<STR_LIT>" <EOL> return self . _last <EOL> def _flush ( self ) : <EOL> if self . _data : <EOL> if self . _last is not None : <EOL> text = string . join ( self . _data , "<STR_LIT>" ) <EOL> if self . _tail : <EOL> assert self . _last . tail is None , "<STR_LIT>" <EOL> self . _last . tail = text <EOL> else : <EOL> assert self . _last . text is None , "<STR_LIT>" <EOL> self . _last . text = text <EOL> self . _data = [ ] <EOL> def data ( self , data ) : <EOL> self . _data . append ( data ) <EOL> def start ( self , tag , attrs ) : <EOL> self . _flush ( ) <EOL> self . _last = elem = self . _factory ( tag , attrs ) <EOL> if self . _elem : <EOL> self . _elem [ - <NUM_LIT:1> ] . append ( elem ) <EOL> self . _elem . append ( elem ) <EOL> self . _tail = <NUM_LIT:0> <EOL> return elem <EOL> def end ( self , tag ) : <EOL> self . _flush ( ) <EOL> self . _last = self . _elem . pop ( ) <EOL> assert self . _last . tag == tag , "<STR_LIT>" % ( <EOL> self . _last . tag , tag ) <EOL> self . _tail = <NUM_LIT:1> <EOL> return self . _last <EOL> class XMLTreeBuilder : <EOL> def __init__ ( self , html = <NUM_LIT:0> , target = None ) : <EOL> try : <EOL> from xml . parsers import expat <EOL> except ImportError : <EOL> raise ImportError ( <EOL> "<STR_LIT>" <EOL> ) <EOL> self . _parser = parser = expat . ParserCreate ( None , "<STR_LIT:}>" ) <EOL> if target is None : <EOL> target = TreeBuilder ( ) <EOL> self . _target = target <EOL> self . _names = { } <EOL> parser . DefaultHandlerExpand = self . _default <EOL> parser . StartElementHandler = self . _start <EOL> parser . EndElementHandler = self . _end <EOL> parser . CharacterDataHandler = self . _data <EOL> try : <EOL> self . _parser . buffer_text = <NUM_LIT:1> <EOL> except AttributeError : <EOL> pass <EOL> try : <EOL> self . _parser . ordered_attributes = <NUM_LIT:1> <EOL> self . _parser . specified_attributes = <NUM_LIT:1> <EOL> parser . StartElementHandler = self . _start_list <EOL> except AttributeError : <EOL> pass <EOL> encoding = None <EOL> if not parser . returns_unicode : <EOL> encoding = "<STR_LIT:utf-8>" <EOL> self . _doctype = None <EOL> self . entity = { } <EOL> def _fixtext ( self , text ) : <EOL> try : <EOL> return _encode ( text , "<STR_LIT:ascii>" ) <EOL> except UnicodeError : <EOL> return text <EOL> def _fixname ( self , key ) : <EOL> try : <EOL> name = self . _names [ key ] <EOL> except KeyError : <EOL> name = key <EOL> if "<STR_LIT:}>" in name : <EOL> name = "<STR_LIT:{>" + name <EOL> self . _names [ key ] = name = self . _fixtext ( name ) <EOL> return name <EOL> def _start ( self , tag , attrib_in ) : <EOL> fixname = self . _fixname <EOL> tag = fixname ( tag ) <EOL> attrib = { } <EOL> for key , value in attrib_in . items ( ) : <EOL> attrib [ fixname ( key ) ] = self . _fixtext ( value ) <EOL> return self . _target . start ( tag , attrib ) <EOL> def _start_list ( self , tag , attrib_in ) : <EOL> fixname = self . _fixname <EOL> tag = fixname ( tag ) <EOL> attrib = { } <EOL> if attrib_in : <EOL> for i in range ( <NUM_LIT:0> , len ( attrib_in ) , <NUM_LIT:2> ) : <EOL> attrib [ fixname ( attrib_in [ i ] ) ] = self . _fixtext ( attrib_in [ i + <NUM_LIT:1> ] ) <EOL> return self . _target . start ( tag , attrib ) <EOL> def _data ( self , text ) : <EOL> return self . _target . data ( self . _fixtext ( text ) ) <EOL> def _end ( self , tag ) : <EOL> return self . _target . end ( self . _fixname ( tag ) ) <EOL> def _default ( self , text ) : <EOL> prefix = text [ : <NUM_LIT:1> ] <EOL> if prefix == "<STR_LIT:&>" : <EOL> try : <EOL> self . _target . data ( self . entity [ text [ <NUM_LIT:1> : - <NUM_LIT:1> ] ] ) <EOL> except KeyError : <EOL> from xml . parsers import expat <EOL> raise expat . error ( <EOL> "<STR_LIT>" % <EOL> ( text , self . _parser . ErrorLineNumber , <EOL> self . _parser . ErrorColumnNumber ) <EOL> ) <EOL> elif prefix == "<STR_LIT:<>" and text [ : <NUM_LIT:9> ] == "<STR_LIT>" : <EOL> self . _doctype = [ ] <EOL> elif self . _doctype is not None : <EOL> if prefix == "<STR_LIT:>>" : <EOL> self . _doctype = None <EOL> return <EOL> text = string . strip ( text ) <EOL> if not text : <EOL> return <EOL> self . _doctype . append ( text ) <EOL> n = len ( self . _doctype ) <EOL> if n > <NUM_LIT:2> : <EOL> type = self . _doctype [ <NUM_LIT:1> ] <EOL> if type == "<STR_LIT>" and n == <NUM_LIT:4> : <EOL> name , type , pubid , system = self . _doctype <EOL> elif type == "<STR_LIT>" and n == <NUM_LIT:3> : <EOL> name , type , system = self . _doctype <EOL> pubid = None <EOL> else : <EOL> return <EOL> if pubid : <EOL> pubid = pubid [ <NUM_LIT:1> : - <NUM_LIT:1> ] <EOL> self . doctype ( name , pubid , system [ <NUM_LIT:1> : - <NUM_LIT:1> ] ) <EOL> self . _doctype = None <EOL> def doctype ( self , name , pubid , system ) : <EOL> pass <EOL> def feed ( self , data ) : <EOL> self . _parser . Parse ( data , <NUM_LIT:0> ) <EOL> def close ( self ) : <EOL> self . _parser . Parse ( "<STR_LIT>" , <NUM_LIT:1> ) <EOL> tree = self . _target . close ( ) <EOL> del self . _target , self . _parser <EOL> return tree </s>
