<s> """<STR_LIT>""" <EOL> class _PythBase ( object ) : <EOL> def __init__ ( self , properties = { } , content = [ ] ) : <EOL> self . properties = { } <EOL> self . content = [ ] <EOL> for ( k , v ) in properties . iteritems ( ) : <EOL> self [ k ] = v <EOL> for item in content : <EOL> self . append ( item ) <EOL> def __setitem__ ( self , key , value ) : <EOL> if key not in self . validProperties : <EOL> raise ValueError ( "<STR_LIT>" % ( self . __class__ . __name__ , repr ( key ) ) ) <EOL> self . properties [ key ] = value <EOL> def __getitem__ ( self , key ) : <EOL> if key not in self . validProperties : <EOL> raise ValueError ( "<STR_LIT>" % <EOL> ( self . __class__ . __name__ , repr ( key ) ) ) <EOL> return self . properties . get ( key ) <EOL> def append ( self , item ) : <EOL> """<STR_LIT>""" <EOL> okay = True <EOL> if not isinstance ( item , self . contentType ) : <EOL> if hasattr ( self . contentType , '<STR_LIT>' ) : <EOL> try : <EOL> item = self . contentType ( content = [ item ] ) <EOL> except TypeError : <EOL> okay = False <EOL> else : <EOL> okay = False <EOL> if not okay : <EOL> raise TypeError ( "<STR_LIT>" % ( <EOL> self . __class__ . __name__ , repr ( type ( item ) ) , repr ( item ) ) ) <EOL> self . content . append ( item ) <EOL> class Text ( _PythBase ) : <EOL> """<STR_LIT>""" <EOL> validProperties = ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:url>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> contentType = unicode <EOL> def __repr__ ( self ) : <EOL> return "<STR_LIT>" % ( "<STR_LIT>" . join ( "<STR_LIT>" % r . encode ( "<STR_LIT:utf-8>" ) for r in self . content ) , self . properties ) <EOL> class Paragraph ( _PythBase ) : <EOL> """<STR_LIT>""" <EOL> validProperties = ( ) <EOL> contentType = Text <EOL> class Image ( Paragraph ) : <EOL> """<STR_LIT>""" <EOL> validProperties = ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> contentType = bytes <EOL> def __repr__ ( self ) : <EOL> return "<STR_LIT>" % ( len ( self . content [ <NUM_LIT:0> ] ) / <NUM_LIT:2> , self . properties ) <EOL> class ListEntry ( _PythBase ) : <EOL> """<STR_LIT>""" <EOL> validProperties = ( ) <EOL> contentType = Paragraph <EOL> class List ( Paragraph ) : <EOL> """<STR_LIT>""" <EOL> validProperties = ( ) <EOL> contentType = ListEntry <EOL> class Document ( _PythBase ) : <EOL> """<STR_LIT>""" <EOL> validProperties = ( '<STR_LIT:title>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> contentType = Paragraph </s>
