Command-line credit parsing

git-svn-id: http://comictagger.googlecode.com/svn/trunk@88 6c5673fe-1810-88d6-992b-cd32ca31540c
This commit is contained in:
beville@gmail.com 2012-11-26 04:09:11 +00:00
parent d05fade731
commit 5eb37200cd
5 changed files with 54 additions and 17 deletions

View File

@ -146,12 +146,26 @@ class GenericMetadata:
# TODO
# not sure if the tags, credits, and pages should broken down, or treated
# as whole lists.... For now, go the easy route, where any overlay
# as whole lists....
for c in new_md.credits:
if c.has_key('primary') and c['primary']:
primary = True
else:
primary = False
# Remove credit role if person is blank
if c['person'] == "":
for r in reversed(self.credits):
if r['role'].lower() == c['role'].lower():
self.credits.remove(r)
else:
self.addCredit( c['person'], c['role'], primary )
# For now, go the easy route, where any overlay
# value wipes out the whole list
if len(new_md.tags) > 0:
assign( "tags", new_md.tags )
if len(new_md.credits) > 0:
assign( "credits", new_md.credits )
if len(new_md.pages) > 0:
assign( "pages", new_md.pages )
@ -163,8 +177,19 @@ class GenericMetadata:
credit['role'] = role
if primary:
credit['primary'] = primary
self.credits.append(credit)
# look to see if it's not already there...
found = False
for c in self.credits:
if ( c['person'].lower() == person.lower() and
c['role'].lower() == role.lower() ):
# no need to add it. just adjust the "primary" flag as needed
c['primary'] = primary
found = True
break
if not found:
self.credits.append(credit)
def __str__( self ):
@ -215,7 +240,10 @@ class GenericMetadata:
add_string( "tags", utils.listToString( self.tags ) )
for c in self.credits:
add_string( "credit", c['role']+": "+c['person'] )
primary = ""
if c.has_key('primary') and c['primary']:
primary == " [P]"
add_string( "credit", c['role']+": "+c['person'] + primary)
# find the longest field name
flen = 0

View File

@ -235,9 +235,9 @@ class IssueIdentifier:
self.log_msg( "\tSeries: " + keys['series'] )
self.log_msg( "\tIssue : " + keys['issue_number'] )
if keys['year'] is not None:
self.log_msg( "\tYear : " + keys['year'] )
self.log_msg( "\tYear : " + str(keys['year']) )
if keys['month'] is not None:
self.log_msg( "\tMonth : " + keys['month'] )
self.log_msg( "\tMonth : " + str(keys['month']) )
self.log_msg("Publisher Blacklist: " + str(self.publisher_blacklist))

View File

@ -128,7 +128,14 @@ If no options are given, {0} will run in windowed mode
key,value = i.split("=")
value = value.replace( replacement_token, "=" ).strip()
key = key.strip()
md_dict[key] = value
if key.lower() == "credit":
cred_attribs = value.split(":")
role = cred_attribs[0]
person = ( cred_attribs[1] if len( cred_attribs ) > 1 else "" )
primary = (cred_attribs[2] if len( cred_attribs ) > 2 else None )
md.addCredit( person.strip(), role.strip(), True if primary is not None else False )
else:
md_dict[key] = value
# Map the dict to the metadata object
for key in md_dict:

View File

@ -61,7 +61,8 @@ def process_file_cli( filename, opts, settings ):
print "Sorry, but "+ filename + " is not a comic archive!"
return
if not ca.isWritableForStyle( opts.data_style ) and ( opts.delete_tags or opts.save_tags or opts.rename_file ):
#if not ca.isWritableForStyle( opts.data_style ) and ( opts.delete_tags or opts.save_tags or opts.rename_file ):
if not ca.isWritable( ) and ( opts.delete_tags or opts.save_tags or opts.rename_file ):
print "This archive is not writable for that tag type"
return
@ -85,7 +86,7 @@ def process_file_cli( filename, opts, settings ):
brief += " tags:[ "
if not (cbi or cix):
brief += "none"
brief += "none "
else:
if cbi: brief += "CBL "
if cix: brief += "CR "

View File

@ -3,19 +3,20 @@ Features
-----------------------------------------------------
CLI
explicit metadata settings option format
-- figure out how to add credits,tags
-- delete tags, credits
Credit overlay:
Just add non-dupes
Create a credit list class to manage
-- figure out how to add tags
-- delete tags
Fix about graphics
Style sheets for windows/mac/linux
-----------------------------------------------------
Bugs
-----------------------------------------------------
Preserve Primary flags in credits
Comma in Credits in CIX
Windows zip and rar: set proper path for writing to archive