#NEWLINE# def convertXMLToMetadata( self , tree ) : #NEWLINE# #INDENT# root = tree . getroot ( ) #NEWLINE# if ( root . tag != 'ComicInfo' ) : #NEWLINE# #INDENT# raise 1 #NEWLINE# return None #NEWLINE# #UNINDENT# metadata = GenericMetadata ( ) #NEWLINE# md = metadata #NEWLINE# def xlate( tag ) : #NEWLINE# #INDENT# node = root . find ( tag ) #NEWLINE# if ( node is not None ) : #NEWLINE# #INDENT# return node . text #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return None #NEWLINE# #UNINDENT# #UNINDENT# md . series = xlate ( 'Series' ) #NEWLINE# md . title = xlate ( 'Title' ) #NEWLINE# md . issue = xlate ( 'Number' ) #NEWLINE# md . issueCount = xlate ( 'Count' ) #NEWLINE# md . volume = xlate ( 'Volume' ) #NEWLINE# md . alternateSeries = xlate ( 'AlternateSeries' ) #NEWLINE# md . alternateNumber = xlate ( 'AlternateNumber' ) #NEWLINE# md . alternateCount = xlate ( 'AlternateCount' ) #NEWLINE# md . comments = xlate ( 'Summary' ) #NEWLINE# md . notes = xlate ( 'Notes' ) #NEWLINE# md . year = xlate ( 'Year' ) #NEWLINE# md . month = xlate ( 'Month' ) #NEWLINE# md . day = xlate ( 'Day' ) #NEWLINE# md . publisher = xlate ( 'Publisher' ) #NEWLINE# md . imprint = xlate ( 'Imprint' ) #NEWLINE# md . genre = xlate ( 'Genre' ) #NEWLINE# md . webLink = xlate ( 'Web' ) #NEWLINE# md . language = xlate ( 'LanguageISO' ) #NEWLINE# md . format = xlate ( 'Format' ) #NEWLINE# md . manga = xlate ( 'Manga' ) #NEWLINE# md . characters = xlate ( 'Characters' ) #NEWLINE# md . teams = xlate ( 'Teams' ) #NEWLINE# md . locations = xlate ( 'Locations' ) #NEWLINE# md . pageCount = xlate ( 'PageCount' ) #NEWLINE# md . scanInfo = xlate ( 'ScanInformation' ) #NEWLINE# md . storyArc = xlate ( 'StoryArc' ) #NEWLINE# md . seriesGroup = xlate ( 'SeriesGroup' ) #NEWLINE# md . maturityRating = xlate ( 'AgeRating' ) #NEWLINE# tmp = xlate ( 'BlackAndWhite' ) #NEWLINE# md . blackAndWhite = False #NEWLINE# if ( ( tmp is not None ) and ( tmp . lower ( ) in [ 'yes' , 'true' , '1' ] ) ) : #NEWLINE# #INDENT# md . blackAndWhite = True #NEWLINE# #UNINDENT# for n in root : #NEWLINE# #INDENT# if ( ( n . tag == 'Writer' ) or ( n . tag == 'Penciller' ) or ( n . tag == 'Inker' ) or ( n . tag == 'Colorist' ) or ( n . tag == 'Letterer' ) or ( n . tag == 'Editor' ) ) : #NEWLINE# #INDENT# if ( n . text is not None ) : #NEWLINE# #INDENT# for name in n . text . split ( ',' ) : #NEWLINE# #INDENT# metadata . addCredit ( name . strip ( ) , n . tag ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if ( n . tag == 'CoverArtist' ) : #NEWLINE# #INDENT# if ( n . text is not None ) : #NEWLINE# #INDENT# for name in n . text . split ( ',' ) : #NEWLINE# #INDENT# metadata . addCredit ( name . strip ( ) , 'Cover' ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# pages_node = root . find ( 'Pages' ) #NEWLINE# if ( pages_node is not None ) : #NEWLINE# #INDENT# for page in pages_node : #NEWLINE# #INDENT# metadata . pages . append ( page . attrib ) #NEWLINE# #UNINDENT# #UNINDENT# metadata . isEmpty = False #NEWLINE# return metadata