<s> """<STR_LIT>""" <EOL> __author__ = "<STR_LIT>" <EOL> __copyright__ = "<STR_LIT>" <EOL> import atom <EOL> import gdata <EOL> BOOK_SEARCH_NAMESPACE = '<STR_LIT>' <EOL> DC_NAMESPACE = '<STR_LIT>' <EOL> ANNOTATION_REL = "<STR_LIT>" <EOL> INFO_REL = "<STR_LIT>" <EOL> LABEL_SCHEME = "<STR_LIT>" <EOL> PREVIEW_REL = "<STR_LIT>" <EOL> THUMBNAIL_REL = "<STR_LIT>" <EOL> FULL_VIEW = "<STR_LIT>" <EOL> PARTIAL_VIEW = "<STR_LIT>" <EOL> NO_VIEW = "<STR_LIT>" <EOL> UNKNOWN_VIEW = "<STR_LIT>" <EOL> EMBEDDABLE = "<STR_LIT>" <EOL> NOT_EMBEDDABLE = "<STR_LIT>" <EOL> class _AtomFromString ( atom . AtomBase ) : <EOL> def FromString ( cls , s ) : <EOL> return atom . CreateClassFromXMLString ( cls , s ) <EOL> FromString = classmethod ( FromString ) <EOL> class Creator ( _AtomFromString ) : <EOL> """<STR_LIT>""" <EOL> _tag = '<STR_LIT>' <EOL> _namespace = DC_NAMESPACE <EOL> class Date ( _AtomFromString ) : <EOL> """<STR_LIT>""" <EOL> _tag = '<STR_LIT:date>' <EOL> _namespace = DC_NAMESPACE <EOL> class Description ( _AtomFromString ) : <EOL> """<STR_LIT>""" <EOL> _tag = '<STR_LIT:description>' <EOL> _namespace = DC_NAMESPACE <EOL> class Format ( _AtomFromString ) : <EOL> """<STR_LIT>""" <EOL> _tag = '<STR_LIT>' <EOL> _namespace = DC_NAMESPACE <EOL> class Identifier ( _AtomFromString ) : <EOL> """<STR_LIT>""" <EOL> _tag = '<STR_LIT>' <EOL> _namespace = DC_NAMESPACE <EOL> class Publisher ( _AtomFromString ) : <EOL> """<STR_LIT>""" <EOL> _tag = '<STR_LIT>' <EOL> _namespace = DC_NAMESPACE <EOL> class Subject ( _AtomFromString ) : <EOL> """<STR_LIT>""" <EOL> _tag = '<STR_LIT>' <EOL> _namespace = DC_NAMESPACE <EOL> class Title ( _AtomFromString ) : <EOL> """<STR_LIT>""" <EOL> _tag = '<STR_LIT:title>' <EOL> _namespace = DC_NAMESPACE <EOL> class Viewability ( _AtomFromString ) : <EOL> """<STR_LIT>""" <EOL> _tag = '<STR_LIT>' <EOL> _namespace = BOOK_SEARCH_NAMESPACE <EOL> _attributes = atom . AtomBase . _attributes . copy ( ) <EOL> _attributes [ '<STR_LIT:value>' ] = '<STR_LIT:value>' <EOL> def __init__ ( self , value = None , text = None , <EOL> extension_elements = None , extension_attributes = None ) : <EOL> self . value = value <EOL> _AtomFromString . __init__ ( self , extension_elements = extension_elements , <EOL> extension_attributes = extension_attributes , text = text ) <EOL> class Embeddability ( _AtomFromString ) : <EOL> """<STR_LIT>""" <EOL> _tag = '<STR_LIT>' <EOL> _namespace = BOOK_SEARCH_NAMESPACE <EOL> _attributes = atom . AtomBase . _attributes . copy ( ) <EOL> _attributes [ '<STR_LIT:value>' ] = '<STR_LIT:value>' <EOL> def __init__ ( self , value = None , text = None , extension_elements = None , <EOL> extension_attributes = None ) : <EOL> self . value = value <EOL> _AtomFromString . __init__ ( self , extension_elements = extension_elements , <EOL> extension_attributes = extension_attributes , text = text ) <EOL> class Review ( _AtomFromString ) : <EOL> """<STR_LIT>""" <EOL> _tag = '<STR_LIT>' <EOL> _namespace = BOOK_SEARCH_NAMESPACE <EOL> _attributes = atom . AtomBase . _attributes . copy ( ) <EOL> _attributes [ '<STR_LIT:type>' ] = '<STR_LIT:type>' <EOL> _attributes [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> def __init__ ( self , type = None , lang = None , text = None , <EOL> extension_elements = None , extension_attributes = None ) : <EOL> self . type = type <EOL> self . lang = lang <EOL> _AtomFromString . __init__ ( self , extension_elements = extension_elements , <EOL> extension_attributes = extension_attributes , text = text ) <EOL> class Rating ( _AtomFromString ) : <EOL> """<STR_LIT>""" <EOL> _tag = '<STR_LIT>' <EOL> _namespace = gdata . GDATA_NAMESPACE <EOL> _attributes = atom . AtomBase . _attributes . copy ( ) <EOL> _attributes [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> _attributes [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> _attributes [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> _attributes [ '<STR_LIT:value>' ] = '<STR_LIT:value>' <EOL> def __init__ ( self , min = None , max = None , average = None , value = None , text = None , <EOL> extension_elements = None , extension_attributes = None ) : <EOL> self . min = min <EOL> self . max = max <EOL> self . average = average <EOL> self . value = value <EOL> _AtomFromString . __init__ ( self , extension_elements = extension_elements , <EOL> extension_attributes = extension_attributes , text = text ) <EOL> class Book ( _AtomFromString , gdata . GDataEntry ) : <EOL> """<STR_LIT>""" <EOL> _tag = '<STR_LIT>' <EOL> _namespace = atom . ATOM_NAMESPACE <EOL> _children = gdata . GDataEntry . _children . copy ( ) <EOL> for i in ( Creator , Identifier , Publisher , Subject , ) : <EOL> _children [ '<STR_LIT>' % ( i . _namespace , i . _tag ) ] = ( i . _tag , [ i ] ) <EOL> for i in ( Date , Description , Format , Viewability , Embeddability , <EOL> Review , Rating ) : <EOL> _children [ '<STR_LIT>' % ( i . _namespace , i . _tag ) ] = ( i . _tag , i ) <EOL> del ( i ) <EOL> _children [ '<STR_LIT>' % ( Title . _namespace , Title . _tag ) ] = ( '<STR_LIT>' , [ Title ] ) <EOL> def to_dict ( self ) : <EOL> """<STR_LIT>""" <EOL> d = { } <EOL> if self . GetAnnotationLink ( ) : <EOL> d [ '<STR_LIT>' ] = self . GetAnnotationLink ( ) . href <EOL> if self . creator : <EOL> d [ '<STR_LIT>' ] = [ x . text for x in self . creator ] <EOL> if self . embeddability : <EOL> d [ '<STR_LIT>' ] = self . embeddability . value . split ( '<STR_LIT:#>' ) [ - <NUM_LIT:1> ] <EOL> if self . date : <EOL> d [ '<STR_LIT:date>' ] = self . date . text <EOL> if self . description : <EOL> d [ '<STR_LIT:description>' ] = self . description . text <EOL> if self . format : <EOL> d [ '<STR_LIT>' ] = self . format . text <EOL> if self . identifier : <EOL> d [ '<STR_LIT>' ] = [ ( '<STR_LIT>' , self . identifier [ <NUM_LIT:0> ] . text ) ] <EOL> for x in self . identifier [ <NUM_LIT:1> : ] : <EOL> l = x . text . split ( '<STR_LIT::>' ) <EOL> d [ '<STR_LIT>' ] . append ( ( l [ <NUM_LIT:0> ] , '<STR_LIT::>' . join ( l [ <NUM_LIT:1> : ] ) ) ) <EOL> if self . GetInfoLink ( ) : <EOL> d [ '<STR_LIT:info>' ] = self . GetInfoLink ( ) . href <EOL> if self . GetPreviewLink ( ) : <EOL> d [ '<STR_LIT>' ] = self . GetPreviewLink ( ) . href <EOL> if self . publisher : <EOL> d [ '<STR_LIT>' ] = [ x . text for x in self . publisher ] <EOL> if self . rating : <EOL> d [ '<STR_LIT>' ] = self . rating . value <EOL> if self . review : <EOL> d [ '<STR_LIT>' ] = self . review . text <EOL> if self . subject : <EOL> d [ '<STR_LIT>' ] = [ x . text for x in self . subject ] <EOL> if self . GetThumbnailLink ( ) : <EOL> d [ '<STR_LIT>' ] = self . GetThumbnailLink ( ) . href <EOL> if self . dc_title : <EOL> d [ '<STR_LIT:title>' ] = '<STR_LIT:U+0020>' . join ( [ x . text for x in self . dc_title ] ) <EOL> if self . viewability : <EOL> d [ '<STR_LIT>' ] = self . viewability . value . split ( '<STR_LIT:#>' ) [ - <NUM_LIT:1> ] <EOL> return d <EOL> def __init__ ( self , creator = None , date = None , <EOL> description = None , format = None , author = None , identifier = None , <EOL> publisher = None , subject = None , dc_title = None , viewability = None , <EOL> embeddability = None , review = None , rating = None , category = None , <EOL> content = None , contributor = None , atom_id = None , link = None , <EOL> published = None , rights = None , source = None , summary = None , <EOL> title = None , control = None , updated = None , text = None , <EOL> extension_elements = None , extension_attributes = None ) : <EOL> self . creator = creator <EOL> self . date = date <EOL> self . description = description <EOL> self . format = format <EOL> self . identifier = identifier <EOL> self . publisher = publisher <EOL> self . subject = subject <EOL> self . dc_title = dc_title or [ ] <EOL> self . viewability = viewability <EOL> self . embeddability = embeddability <EOL> self . review = review <EOL> self . rating = rating <EOL> gdata . GDataEntry . __init__ ( self , author = author , category = category , <EOL> content = content , contributor = contributor , atom_id = atom_id , <EOL> link = link , published = published , rights = rights , source = source , <EOL> summary = summary , title = title , control = control , updated = updated , <EOL> text = text , extension_elements = extension_elements , <EOL> extension_attributes = extension_attributes ) <EOL> def GetThumbnailLink ( self ) : <EOL> """<STR_LIT>""" <EOL> for i in self . link : <EOL> if i . rel == THUMBNAIL_REL : <EOL> return i <EOL> def GetInfoLink ( self ) : <EOL> """<STR_LIT>""" <EOL> for i in self . link : <EOL> if i . rel == INFO_REL : <EOL> return i <EOL> def GetPreviewLink ( self ) : <EOL> """<STR_LIT>""" <EOL> for i in self . link : <EOL> if i . rel == PREVIEW_REL : <EOL> return i <EOL> def GetAnnotationLink ( self ) : <EOL> """<STR_LIT>""" <EOL> for i in self . link : <EOL> if i . rel == ANNOTATION_REL : <EOL> return i <EOL> def set_rating ( self , value ) : <EOL> """<STR_LIT>""" <EOL> assert ( value in ( '<STR_LIT:1>' , '<STR_LIT:2>' , '<STR_LIT:3>' , '<STR_LIT:4>' , '<STR_LIT:5>' ) ) <EOL> if not isinstance ( self . rating , Rating ) : <EOL> self . rating = Rating ( ) <EOL> self . rating . value = value <EOL> def set_review ( self , text , type = '<STR_LIT:text>' , lang = '<STR_LIT>' ) : <EOL> """<STR_LIT>""" <EOL> self . review = Review ( text = text , type = type , lang = lang ) <EOL> def get_label ( self ) : <EOL> """<STR_LIT>""" <EOL> for i in self . category : <EOL> if i . scheme == LABEL_SCHEME : <EOL> return i . term <EOL> def set_label ( self , term ) : <EOL> """<STR_LIT>""" <EOL> self . remove_label ( ) <EOL> self . category . append ( atom . Category ( term = term , scheme = LABEL_SCHEME ) ) <EOL> def remove_label ( self ) : <EOL> """<STR_LIT>""" <EOL> ln = len ( self . category ) <EOL> for i , j in enumerate ( self . category [ : : - <NUM_LIT:1> ] ) : <EOL> if j . scheme == LABEL_SCHEME : <EOL> del ( self . category [ ln - <NUM_LIT:1> - i ] ) <EOL> def clean_annotations ( self ) : <EOL> """<STR_LIT>""" <EOL> self . remove_label ( ) <EOL> self . review = None <EOL> self . rating = None <EOL> def get_google_id ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . id . text . split ( '<STR_LIT:/>' ) [ - <NUM_LIT:1> ] <EOL> class BookFeed ( _AtomFromString , gdata . GDataFeed ) : <EOL> """<STR_LIT>""" <EOL> _tag = '<STR_LIT>' <EOL> _namespace = atom . ATOM_NAMESPACE <EOL> _children = gdata . GDataFeed . _children . copy ( ) <EOL> _children [ '<STR_LIT>' % ( Book . _namespace , Book . _tag ) ] = ( Book . _tag , [ Book ] ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> import doctest <EOL> doctest . testfile ( '<STR_LIT>' ) </s>
