autopep8 -a
—aggressive, level 1
This commit is contained in:
parent
79103990fa
commit
ee52448f17
@ -30,7 +30,7 @@ import utils
|
||||
|
||||
class AutoTagStartWindow(QtGui.QDialog):
|
||||
|
||||
def __init__(self, parent, settings, msg):
|
||||
def __init__(self, parent, settings, msg):
|
||||
super(AutoTagStartWindow, self).__init__(parent)
|
||||
|
||||
uic.loadUi(
|
||||
|
@ -71,7 +71,7 @@ def actual_issue_data_fetch(match, settings, opts):
|
||||
comicVine = ComicVineTalker()
|
||||
comicVine.wait_for_rate_limit = opts.wait_and_retry_on_rate_limit
|
||||
cv_md = comicVine.fetchIssueData(
|
||||
match['volume_id'], match['issue_number'], settings)
|
||||
match['volume_id'], match['issue_number'], settings)
|
||||
except ComicVineTalkerException:
|
||||
print >> sys.stderr, "Network error while getting issue details. Save aborted"
|
||||
return None
|
||||
@ -119,7 +119,8 @@ def display_match_set_for_choice(label, match_set, opts, settings):
|
||||
if opts.interactive:
|
||||
while True:
|
||||
i = raw_input("Choose a match #, or 's' to skip: ")
|
||||
if (i.isdigit() and int(i) in range(1, len(match_set.matches) + 1)) or i == 's':
|
||||
if (i.isdigit() and int(i) in range(
|
||||
1, len(match_set.matches) + 1)) or i == 's':
|
||||
break
|
||||
if i != 's':
|
||||
i = int(i) - 1
|
||||
@ -187,7 +188,7 @@ def cli_mode(opts, settings):
|
||||
match_results = OnlineMatchResults()
|
||||
|
||||
for f in opts.file_list:
|
||||
if type(f) == str:
|
||||
if isinstance(f, str):
|
||||
f = f.decode(filename_encoding, 'replace')
|
||||
process_file_cli(f, opts, settings, match_results)
|
||||
sys.stdout.flush()
|
||||
@ -231,7 +232,8 @@ def process_file_cli(filename, opts, settings, match_results):
|
||||
|
||||
# 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.copy_tags or opts.save_tags or opts.rename_file):
|
||||
if not ca.isWritable() and (
|
||||
opts.delete_tags or opts.copy_tags or opts.save_tags or opts.rename_file):
|
||||
print >> sys.stderr, "This archive is not writable for that tag type"
|
||||
return
|
||||
|
||||
@ -263,7 +265,8 @@ def process_file_cli(filename, opts, settings, match_results):
|
||||
brief += "({0: >3} pages)".format(page_count)
|
||||
brief += " tags:[ "
|
||||
|
||||
if not (has[MetaDataStyle.CBI] or has[MetaDataStyle.CIX] or has[MetaDataStyle.COMET]):
|
||||
if not (has[MetaDataStyle.CBI] or has[
|
||||
MetaDataStyle.CIX] or has[MetaDataStyle.COMET]):
|
||||
brief += "none "
|
||||
else:
|
||||
if has[MetaDataStyle.CBI]:
|
||||
|
@ -182,7 +182,7 @@ class ZipArchiver:
|
||||
# walk backwards to find the "End of Central Directory" record
|
||||
while (not found) and (-pos != file_length):
|
||||
# seek, relative to EOF
|
||||
fo.seek(pos, 2)
|
||||
fo.seek(pos, 2)
|
||||
|
||||
value = fo.read(4)
|
||||
|
||||
@ -198,7 +198,7 @@ class ZipArchiver:
|
||||
|
||||
# now skip forward 20 bytes to the comment length word
|
||||
pos += 20
|
||||
fo.seek(pos, 2)
|
||||
fo.seek(pos, 2)
|
||||
|
||||
# Pack the length of the comment string
|
||||
format = "H" # one 2-byte integer
|
||||
@ -207,7 +207,7 @@ class ZipArchiver:
|
||||
|
||||
# write out the length
|
||||
fo.write(comment_length)
|
||||
fo.seek(pos + 2, 2)
|
||||
fo.seek(pos + 2, 2)
|
||||
|
||||
# write out the comment itself
|
||||
fo.write(comment)
|
||||
@ -734,14 +734,14 @@ class ComicArchive:
|
||||
for name in name_list:
|
||||
fname = os.path.split(name)[1]
|
||||
length = len(fname)
|
||||
if length_buckets.has_key(length):
|
||||
if length in length_buckets:
|
||||
length_buckets[length] += 1
|
||||
else:
|
||||
length_buckets[length] = 1
|
||||
|
||||
# sort by most common
|
||||
sorted_buckets = sorted(
|
||||
length_buckets.iteritems(), key=lambda (k, v): (v, k), reverse=True)
|
||||
length_buckets.iteritems(), key=lambda k_v: (k_v[1], k_v[0]), reverse=True)
|
||||
|
||||
# statistical mode occurence is first
|
||||
mode_length = sorted_buckets[0][0]
|
||||
@ -789,7 +789,8 @@ class ComicArchive:
|
||||
# make a sub-list of image files
|
||||
self.page_list = []
|
||||
for name in files:
|
||||
if (name[-4:].lower() in [".jpg", "jpeg", ".png", ".gif", "webp"] and os.path.basename(name)[0] != "."):
|
||||
if (name[-4:].lower() in [".jpg", "jpeg", ".png",
|
||||
".gif", "webp"] and os.path.basename(name)[0] != "."):
|
||||
self.page_list.append(name)
|
||||
|
||||
return self.page_list
|
||||
|
@ -140,7 +140,7 @@ class ComicBookInfo:
|
||||
|
||||
return cbi_container
|
||||
|
||||
def writeToExternalFile(self, filename, metadata):
|
||||
def writeToExternalFile(self, filename, metadata):
|
||||
|
||||
cbi_container = self.createJSONDictionary(metadata)
|
||||
|
||||
|
@ -259,11 +259,11 @@ class ComicVineCacher:
|
||||
pub_name = cv_volume_record['publisher']['name']
|
||||
|
||||
data = {
|
||||
"name": cv_volume_record['name'],
|
||||
"publisher": pub_name,
|
||||
"name": cv_volume_record['name'],
|
||||
"publisher": pub_name,
|
||||
"count_of_issues": cv_volume_record['count_of_issues'],
|
||||
"start_year": cv_volume_record['start_year'],
|
||||
"timestamp": timestamp
|
||||
"start_year": cv_volume_record['start_year'],
|
||||
"timestamp": timestamp
|
||||
}
|
||||
self.upsert(cur, "volumes", "id", cv_volume_record['id'], data)
|
||||
|
||||
@ -282,15 +282,15 @@ class ComicVineCacher:
|
||||
for issue in cv_volume_issues:
|
||||
|
||||
data = {
|
||||
"volume_id": volume_id,
|
||||
"name": issue['name'],
|
||||
"issue_number": issue['issue_number'],
|
||||
"volume_id": volume_id,
|
||||
"name": issue['name'],
|
||||
"issue_number": issue['issue_number'],
|
||||
"site_detail_url": issue['site_detail_url'],
|
||||
"cover_date": issue['cover_date'],
|
||||
"super_url": issue['image']['super_url'],
|
||||
"thumb_url": issue['image']['thumb_url'],
|
||||
"description": issue['description'],
|
||||
"timestamp": timestamp
|
||||
"cover_date": issue['cover_date'],
|
||||
"super_url": issue['image']['super_url'],
|
||||
"thumb_url": issue['image']['thumb_url'],
|
||||
"description": issue['description'],
|
||||
"timestamp": timestamp
|
||||
}
|
||||
self.upsert(cur, "issues", "id", issue['id'], data)
|
||||
|
||||
@ -373,7 +373,8 @@ class ComicVineCacher:
|
||||
|
||||
return results
|
||||
|
||||
def add_issue_select_details(self, issue_id, image_url, thumb_image_url, cover_date, site_detail_url):
|
||||
def add_issue_select_details(
|
||||
self, issue_id, image_url, thumb_image_url, cover_date, site_detail_url):
|
||||
|
||||
con = lite.connect(self.db_file)
|
||||
|
||||
|
@ -157,7 +157,8 @@ class ComicVineTalker(QObject):
|
||||
while True:
|
||||
content = self.getUrlContent(url)
|
||||
cv_response = json.loads(content)
|
||||
if self.wait_for_rate_limit and cv_response['status_code'] == ComicVineTalkerException.RateLimit:
|
||||
if self.wait_for_rate_limit and cv_response[
|
||||
'status_code'] == ComicVineTalkerException.RateLimit:
|
||||
self.writeLog(
|
||||
"Rate limit encountered. Waiting for {0} minutes\n".format(limit_wait_time))
|
||||
time.sleep(limit_wait_time * 60)
|
||||
@ -351,7 +352,8 @@ class ComicVineTalker(QObject):
|
||||
|
||||
return volume_issues_result
|
||||
|
||||
def fetchIssuesByVolumeIssueNumAndYear(self, volume_id_list, issue_number, year):
|
||||
def fetchIssuesByVolumeIssueNumAndYear(
|
||||
self, volume_id_list, issue_number, year):
|
||||
volume_filter = "volume:"
|
||||
for vid in volume_id_list:
|
||||
volume_filter += str(vid) + "|"
|
||||
@ -409,7 +411,8 @@ class ComicVineTalker(QObject):
|
||||
for record in issues_list_results:
|
||||
if IssueString(issue_number).asString() is None:
|
||||
issue_number = 1
|
||||
if IssueString(record['issue_number']).asString().lower() == IssueString(issue_number).asString().lower():
|
||||
if IssueString(record['issue_number']).asString().lower() == IssueString(
|
||||
issue_number).asString().lower():
|
||||
found = True
|
||||
break
|
||||
|
||||
@ -425,7 +428,8 @@ class ComicVineTalker(QObject):
|
||||
return None
|
||||
|
||||
# now, map the comicvine data to generic metadata
|
||||
return self.mapCVDataToMetadata(volume_results, issue_results, settings)
|
||||
return self.mapCVDataToMetadata(
|
||||
volume_results, issue_results, settings)
|
||||
|
||||
def fetchIssueDataByIssueID(self, issue_id, settings):
|
||||
|
||||
@ -473,7 +477,7 @@ class ComicVineTalker(QObject):
|
||||
|
||||
person_credits = issue_results['person_credits']
|
||||
for person in person_credits:
|
||||
if person.has_key('role'):
|
||||
if 'role' in person:
|
||||
roles = person['role'].split(',')
|
||||
for role in roles:
|
||||
# can we determine 'primary' from CV??
|
||||
@ -656,7 +660,8 @@ class ComicVineTalker(QObject):
|
||||
cvc = ComicVineCacher()
|
||||
return cvc.get_issue_select_details(issue_id)
|
||||
|
||||
def cacheIssueSelectDetails(self, issue_id, image_url, thumb_url, cover_date, page_url):
|
||||
def cacheIssueSelectDetails(
|
||||
self, issue_id, image_url, thumb_url, cover_date, page_url):
|
||||
cvc = ComicVineCacher()
|
||||
cvc.add_issue_select_details(
|
||||
issue_id, image_url, thumb_url, cover_date, page_url)
|
||||
@ -687,7 +692,7 @@ class ComicVineTalker(QObject):
|
||||
div_list = soup.find_all('div')
|
||||
covers_found = 0
|
||||
for d in div_list:
|
||||
if d.has_key('class'):
|
||||
if 'class' in d:
|
||||
c = d['class']
|
||||
if 'imgboxart' in c and 'issue-cover' in c:
|
||||
covers_found += 1
|
||||
@ -738,12 +743,12 @@ class ComicVineTalker(QObject):
|
||||
try:
|
||||
cv_response = json.loads(str(data))
|
||||
except:
|
||||
print >> sys.stderr, "Comic Vine query failed to get JSON data"
|
||||
print >> sys.stderr, "Comic Vine query failed to get JSON data"
|
||||
print >> sys.stderr, str(data)
|
||||
return
|
||||
|
||||
if cv_response['status_code'] != 1:
|
||||
print >> sys.stderr, "Comic Vine query failed with error: [{0}]. ".format(
|
||||
print >> sys.stderr, "Comic Vine query failed with error: [{0}]. ".format(
|
||||
cv_response['error'])
|
||||
return
|
||||
|
||||
|
@ -181,7 +181,7 @@ class CoverImageWidget(QWidget):
|
||||
self.comicVine.altUrlListFetchComplete.connect(
|
||||
self.altCoverUrlListFetchComplete)
|
||||
self.comicVine.asyncFetchAlternateCoverURLs(
|
||||
int(self.issue_id), issue_page_url)
|
||||
int(self.issue_id), issue_page_url)
|
||||
|
||||
def altCoverUrlListFetchComplete(self, url_list, issue_id):
|
||||
if len(url_list) > 0:
|
||||
@ -201,7 +201,7 @@ class CoverImageWidget(QWidget):
|
||||
def updateImage(self):
|
||||
if self.imageIndex == -1:
|
||||
self.loadDefault()
|
||||
elif self.mode in [CoverImageWidget.AltCoverMode, CoverImageWidget.URLMode]:
|
||||
elif self.mode in [CoverImageWidget.AltCoverMode, CoverImageWidget.URLMode]:
|
||||
self.loadURL()
|
||||
elif self.mode == CoverImageWidget.DataMode:
|
||||
self.coverRemoteFetchComplete(self.imageData, 0)
|
||||
|
@ -36,7 +36,7 @@ class ExportConflictOpts:
|
||||
|
||||
class ExportWindow(QtGui.QDialog):
|
||||
|
||||
def __init__(self, parent, settings, msg):
|
||||
def __init__(self, parent, settings, msg):
|
||||
super(ExportWindow, self).__init__(parent)
|
||||
|
||||
uic.loadUi(ComicTaggerSettings.getUIFile('exportwindow.ui'), self)
|
||||
|
@ -58,7 +58,7 @@ class FileNameParser:
|
||||
found = True
|
||||
|
||||
if not found:
|
||||
match = re.search('(?<=\(of\s)\d+(?=\))', tmpstr, re.IGNORECASE)
|
||||
match = re.search('(?<=\(of\s)\d+(?=\))', tmpstr, re.IGNORECASE)
|
||||
if match:
|
||||
count = match.group()
|
||||
found = True
|
||||
|
@ -98,7 +98,8 @@ class FileRenamer:
|
||||
new_name = self.replaceToken(new_name, md.month, '%month%')
|
||||
month_name = None
|
||||
if md.month is not None:
|
||||
if (type(md.month) == str and md.month.isdigit()) or type(md.month) == int:
|
||||
if (isinstance(md.month, str) and md.month.isdigit()) or isinstance(
|
||||
md.month, int):
|
||||
if int(md.month) in range(1, 13):
|
||||
dt = datetime.datetime(1970, int(md.month), 1, 0, 0)
|
||||
month_name = dt.strftime(
|
||||
@ -152,8 +153,8 @@ class FileRenamer:
|
||||
# some tweaks to keep various filesystems happy
|
||||
new_name = new_name.replace("/", "-")
|
||||
new_name = new_name.replace(" :", " -")
|
||||
new_name = new_name.replace(": ", " - ")
|
||||
new_name = new_name.replace(":", "-")
|
||||
new_name = new_name.replace(": ", " - ")
|
||||
new_name = new_name.replace(":", "-")
|
||||
new_name = new_name.replace("?", "")
|
||||
|
||||
return new_name
|
||||
|
@ -116,7 +116,7 @@ class GenericMetadata:
|
||||
|
||||
def assign(cur, new):
|
||||
if new is not None:
|
||||
if type(new) == str and len(new) == 0:
|
||||
if isinstance(new, str) and len(new) == 0:
|
||||
setattr(self, cur, None)
|
||||
else:
|
||||
setattr(self, cur, new)
|
||||
@ -171,14 +171,14 @@ class GenericMetadata:
|
||||
# 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)
|
||||
assign("tags", new_md.tags)
|
||||
|
||||
if len(new_md.pages) > 0:
|
||||
assign("pages", new_md.pages)
|
||||
assign("pages", new_md.pages)
|
||||
|
||||
def overlayCredits(self, new_credits):
|
||||
for c in new_credits:
|
||||
if c.has_key('primary') and c['primary']:
|
||||
if 'primary' in c and c['primary']:
|
||||
primary = True
|
||||
else:
|
||||
primary = False
|
||||
@ -295,13 +295,13 @@ class GenericMetadata:
|
||||
add_attr_string("comments")
|
||||
add_attr_string("notes")
|
||||
|
||||
add_string("tags", utils.listToString(self.tags))
|
||||
add_string("tags", utils.listToString(self.tags))
|
||||
|
||||
for c in self.credits:
|
||||
primary = ""
|
||||
if c.has_key('primary') and c['primary']:
|
||||
if 'primary' in c and c['primary']:
|
||||
primary = " [P]"
|
||||
add_string("credit", c['role'] + ": " + c['person'] + primary)
|
||||
add_string("credit", c['role'] + ": " + c['person'] + primary)
|
||||
|
||||
# find the longest field name
|
||||
flen = 0
|
||||
|
@ -20,6 +20,7 @@ limitations under the License.
|
||||
|
||||
import StringIO
|
||||
import sys
|
||||
from functools import reduce
|
||||
|
||||
try:
|
||||
from PIL import Image
|
||||
@ -67,7 +68,8 @@ class ImageHasher(object):
|
||||
bitlist = map(compare_value_to_avg, pixels)
|
||||
|
||||
# build up an int value from the bit list, one bit at a time
|
||||
def set_bit(x, (idx, val)):
|
||||
def set_bit(x, idx_val):
|
||||
(idx, val) = idx_val
|
||||
return (x | (val << idx))
|
||||
|
||||
result = reduce(set_bit, enumerate(bitlist), 0)
|
||||
@ -180,7 +182,7 @@ class ImageHasher(object):
|
||||
|
||||
@staticmethod
|
||||
def hamming_distance(h1, h2):
|
||||
if type(h1) == long or type(h1) == int:
|
||||
if isinstance(h1, long) or isinstance(h1, int):
|
||||
n1 = h1
|
||||
n2 = h2
|
||||
else:
|
||||
|
@ -72,7 +72,8 @@ class ImagePopup(QtGui.QDialog):
|
||||
win_h = self.height()
|
||||
win_w = self.width()
|
||||
|
||||
if self.imagePixmap.width() > win_w or self.imagePixmap.height() > win_h:
|
||||
if self.imagePixmap.width(
|
||||
) > win_w or self.imagePixmap.height() > win_h:
|
||||
# scale the pixmap to fit in the frame
|
||||
display_pixmap = self.imagePixmap.scaled(
|
||||
win_w, win_h, QtCore.Qt.KeepAspectRatio)
|
||||
|
@ -243,7 +243,8 @@ class IssueIdentifier:
|
||||
if newline:
|
||||
self.output_function("\n")
|
||||
|
||||
def getIssueCoverMatchScore(self, comicVine, issue_id, primary_img_url, primary_thumb_url, page_url, localCoverHashList, useRemoteAlternates=False, useLog=True):
|
||||
def getIssueCoverMatchScore(self, comicVine, issue_id, primary_img_url, primary_thumb_url,
|
||||
page_url, localCoverHashList, useRemoteAlternates=False, useLog=True):
|
||||
# localHashes is a list of pre-calculated hashs.
|
||||
# useRemoteAlternates - indicates to use alternate covers from CV
|
||||
|
||||
@ -415,7 +416,7 @@ class IssueIdentifier:
|
||||
if self.cancel == True:
|
||||
return []
|
||||
|
||||
if cv_search_results == None:
|
||||
if cv_search_results is None:
|
||||
return []
|
||||
|
||||
series_second_round_list = []
|
||||
@ -427,7 +428,8 @@ class IssueIdentifier:
|
||||
date_approved = True
|
||||
|
||||
# remove any series that starts after the issue year
|
||||
if keys['year'] is not None and str(keys['year']).isdigit() and item['start_year'] is not None and str(item['start_year']).isdigit():
|
||||
if keys['year'] is not None and str(keys['year']).isdigit() and item[
|
||||
'start_year'] is not None and str(item['start_year']).isdigit():
|
||||
if int(keys['year']) < int(item['start_year']):
|
||||
date_approved = False
|
||||
|
||||
@ -435,13 +437,15 @@ class IssueIdentifier:
|
||||
# within ,e.g. 5 chars
|
||||
shortened_key = utils.removearticles(keys['series'])
|
||||
shortened_item_name = utils.removearticles(item['name'])
|
||||
if len(shortened_item_name) < (len(shortened_key) + self.length_delta_thresh):
|
||||
if len(shortened_item_name) < (
|
||||
len(shortened_key) + self.length_delta_thresh):
|
||||
length_approved = True
|
||||
|
||||
# remove any series from publishers on the blacklist
|
||||
if item['publisher'] is not None:
|
||||
publisher = item['publisher']['name']
|
||||
if publisher is not None and publisher.lower() in self.publisher_blacklist:
|
||||
if publisher is not None and publisher.lower(
|
||||
) in self.publisher_blacklist:
|
||||
publisher_approved = False
|
||||
|
||||
if length_approved and publisher_approved and date_approved:
|
||||
@ -654,7 +658,8 @@ class IssueIdentifier:
|
||||
# One more test for the case choosing limited series first issue vs a trade with the same cover:
|
||||
# if we have a given issue count > 1 and the volume from CV has
|
||||
# count==1, remove it from match list
|
||||
if len(self.match_list) >= 2 and keys['issue_count'] is not None and keys['issue_count'] != 1:
|
||||
if len(self.match_list) >= 2 and keys[
|
||||
'issue_count'] is not None and keys['issue_count'] != 1:
|
||||
new_list = list()
|
||||
for match in self.match_list:
|
||||
if match['cv_issue_count'] != 1:
|
||||
|
@ -151,7 +151,8 @@ class IssueSelectionWindow(QtGui.QDialog):
|
||||
item.setFlags(QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled)
|
||||
self.twList.setItem(row, 2, item)
|
||||
|
||||
if IssueString(record['issue_number']).asString().lower() == IssueString(self.issue_number).asString().lower():
|
||||
if IssueString(record['issue_number']).asString().lower() == IssueString(
|
||||
self.issue_number).asString().lower():
|
||||
self.initial_id = record['id']
|
||||
|
||||
row += 1
|
||||
|
@ -46,7 +46,7 @@ class IssueString:
|
||||
if text is None:
|
||||
return
|
||||
|
||||
if type(text) == int:
|
||||
if isinstance(text, int):
|
||||
text = str(text)
|
||||
|
||||
if len(text) == 0:
|
||||
|
@ -40,7 +40,8 @@ StyleQuestion = 1
|
||||
|
||||
class OptionalMessageDialog(QDialog):
|
||||
|
||||
def __init__(self, parent, style, title, msg, check_state=Qt.Unchecked, check_text=None):
|
||||
def __init__(self, parent, style, title, msg,
|
||||
check_state=Qt.Unchecked, check_text=None):
|
||||
QDialog.__init__(self, parent)
|
||||
|
||||
self.setWindowTitle(title)
|
||||
@ -100,7 +101,8 @@ class OptionalMessageDialog(QDialog):
|
||||
return d.theCheckBox.isChecked()
|
||||
|
||||
@staticmethod
|
||||
def question(parent, title, msg, check_state=Qt.Unchecked, check_text=None):
|
||||
def question(
|
||||
parent, title, msg, check_state=Qt.Unchecked, check_text=None):
|
||||
|
||||
d = OptionalMessageDialog(
|
||||
parent, StyleQuestion, title, msg, check_state=check_state, check_text=check_text)
|
||||
|
@ -232,7 +232,8 @@ For more help visit the wiki at: http://code.google.com/p/comictagger/
|
||||
|
||||
def parseCmdLineArgs(self):
|
||||
|
||||
if platform.system() == "Darwin" and hasattr(sys, "frozen") and sys.frozen == 1:
|
||||
if platform.system() == "Darwin" and hasattr(
|
||||
sys, "frozen") and sys.frozen == 1:
|
||||
# remove the PSN ("process serial number") argument from OS/X
|
||||
input_args = [a for a in sys.argv[1:] if "-psn_0_" not in a]
|
||||
else:
|
||||
@ -391,10 +392,11 @@ For more help visit the wiki at: http://code.google.com/p/comictagger/
|
||||
self.filename = args[0]
|
||||
self.file_list = args
|
||||
|
||||
if self.only_set_key and self.cv_api_key == None:
|
||||
if self.only_set_key and self.cv_api_key is None:
|
||||
self.display_msg_and_quit("Key not given!", 1)
|
||||
|
||||
if (self.only_set_key == False) and self.no_gui and (self.filename is None):
|
||||
if (self.only_set_key == False) and self.no_gui and (
|
||||
self.filename is None):
|
||||
self.display_msg_and_quit(
|
||||
"Command requires at least one filename!", 1)
|
||||
|
||||
|
@ -185,7 +185,8 @@ class PageListEditor(QWidget):
|
||||
for i in range(self.listWidget.count()):
|
||||
item = self.listWidget.item(i)
|
||||
page_dict = item.data(Qt.UserRole).toPyObject()[0]
|
||||
if 'Type' in page_dict and page_dict['Type'] == PageType.FrontCover:
|
||||
if 'Type' in page_dict and page_dict[
|
||||
'Type'] == PageType.FrontCover:
|
||||
frontCover = int(page_dict['Image'])
|
||||
break
|
||||
return frontCover
|
||||
|
@ -264,7 +264,8 @@ class ComicTaggerSettings:
|
||||
if self.config.has_option('dialogflags', 'show_disclaimer'):
|
||||
self.show_disclaimer = self.config.getboolean(
|
||||
'dialogflags', 'show_disclaimer')
|
||||
if self.config.has_option('dialogflags', 'dont_notify_about_this_version'):
|
||||
if self.config.has_option(
|
||||
'dialogflags', 'dont_notify_about_this_version'):
|
||||
self.dont_notify_about_this_version = self.config.get(
|
||||
'dialogflags', 'dont_notify_about_this_version')
|
||||
if self.config.has_option('dialogflags', 'ask_about_usage_stats'):
|
||||
@ -277,7 +278,8 @@ class ComicTaggerSettings:
|
||||
if self.config.has_option('comicvine', 'use_series_start_as_volume'):
|
||||
self.use_series_start_as_volume = self.config.getboolean(
|
||||
'comicvine', 'use_series_start_as_volume')
|
||||
if self.config.has_option('comicvine', 'clear_form_before_populating_from_cv'):
|
||||
if self.config.has_option(
|
||||
'comicvine', 'clear_form_before_populating_from_cv'):
|
||||
self.clear_form_before_populating_from_cv = self.config.getboolean(
|
||||
'comicvine', 'clear_form_before_populating_from_cv')
|
||||
if self.config.has_option('comicvine', 'remove_html_tables'):
|
||||
@ -286,7 +288,8 @@ class ComicTaggerSettings:
|
||||
if self.config.has_option('comicvine', 'cv_api_key'):
|
||||
self.cv_api_key = self.config.get('comicvine', 'cv_api_key')
|
||||
|
||||
if self.config.has_option('cbl_transform', 'assume_lone_credit_is_primary'):
|
||||
if self.config.has_option(
|
||||
'cbl_transform', 'assume_lone_credit_is_primary'):
|
||||
self.assume_lone_credit_is_primary = self.config.getboolean(
|
||||
'cbl_transform', 'assume_lone_credit_is_primary')
|
||||
if self.config.has_option('cbl_transform', 'copy_characters_to_tags'):
|
||||
@ -307,10 +310,12 @@ class ComicTaggerSettings:
|
||||
if self.config.has_option('cbl_transform', 'copy_weblink_to_comments'):
|
||||
self.copy_weblink_to_comments = self.config.getboolean(
|
||||
'cbl_transform', 'copy_weblink_to_comments')
|
||||
if self.config.has_option('cbl_transform', 'apply_cbl_transform_on_cv_import'):
|
||||
if self.config.has_option(
|
||||
'cbl_transform', 'apply_cbl_transform_on_cv_import'):
|
||||
self.apply_cbl_transform_on_cv_import = self.config.getboolean(
|
||||
'cbl_transform', 'apply_cbl_transform_on_cv_import')
|
||||
if self.config.has_option('cbl_transform', 'apply_cbl_transform_on_bulk_operation'):
|
||||
if self.config.has_option(
|
||||
'cbl_transform', 'apply_cbl_transform_on_bulk_operation'):
|
||||
self.apply_cbl_transform_on_bulk_operation = self.config.getboolean(
|
||||
'cbl_transform', 'apply_cbl_transform_on_bulk_operation')
|
||||
|
||||
@ -322,7 +327,8 @@ class ComicTaggerSettings:
|
||||
if self.config.has_option('rename', 'rename_use_smart_string_cleanup'):
|
||||
self.rename_use_smart_string_cleanup = self.config.getboolean(
|
||||
'rename', 'rename_use_smart_string_cleanup')
|
||||
if self.config.has_option('rename', 'rename_extension_based_on_archive'):
|
||||
if self.config.has_option(
|
||||
'rename', 'rename_extension_based_on_archive'):
|
||||
self.rename_extension_based_on_archive = self.config.getboolean(
|
||||
'rename', 'rename_extension_based_on_archive')
|
||||
|
||||
@ -335,10 +341,12 @@ class ComicTaggerSettings:
|
||||
if self.config.has_option('autotag', 'assume_1_if_no_issue_num'):
|
||||
self.assume_1_if_no_issue_num = self.config.getboolean(
|
||||
'autotag', 'assume_1_if_no_issue_num')
|
||||
if self.config.has_option('autotag', 'ignore_leading_numbers_in_filename'):
|
||||
if self.config.has_option(
|
||||
'autotag', 'ignore_leading_numbers_in_filename'):
|
||||
self.ignore_leading_numbers_in_filename = self.config.getboolean(
|
||||
'autotag', 'ignore_leading_numbers_in_filename')
|
||||
if self.config.has_option('autotag', 'remove_archive_after_successful_match'):
|
||||
if self.config.has_option(
|
||||
'autotag', 'remove_archive_after_successful_match'):
|
||||
self.remove_archive_after_successful_match = self.config.getboolean(
|
||||
'autotag', 'remove_archive_after_successful_match')
|
||||
if self.config.has_option('autotag', 'wait_and_retry_on_rate_limit'):
|
||||
@ -351,8 +359,8 @@ class ComicTaggerSettings:
|
||||
self.config.add_section('settings')
|
||||
|
||||
self.config.set(
|
||||
'settings', 'check_for_new_version', self.check_for_new_version)
|
||||
self.config.set('settings', 'rar_exe_path', self.rar_exe_path)
|
||||
'settings', 'check_for_new_version', self.check_for_new_version)
|
||||
self.config.set('settings', 'rar_exe_path', self.rar_exe_path)
|
||||
self.config.set('settings', 'unrar_exe_path', self.unrar_exe_path)
|
||||
self.config.set('settings', 'send_usage_stats', self.send_usage_stats)
|
||||
|
||||
|
@ -114,7 +114,8 @@ class TaggerWindow(QtGui.QMainWindow):
|
||||
self.onIncomingSocketConnection)
|
||||
ok = self.socketServer.listen(settings.install_id)
|
||||
if not ok:
|
||||
if self.socketServer.serverError() == QtNetwork.QAbstractSocket.AddressInUseError:
|
||||
if self.socketServer.serverError(
|
||||
) == QtNetwork.QAbstractSocket.AddressInUseError:
|
||||
#print("Resetting unresponsive socket with key [{}]".format(settings.install_id))
|
||||
self.socketServer.removeServer(settings.install_id)
|
||||
ok = self.socketServer.listen(settings.install_id)
|
||||
@ -755,30 +756,30 @@ class TaggerWindow(QtGui.QMainWindow):
|
||||
|
||||
md = self.metadata
|
||||
|
||||
assignText(self.leSeries, md.series)
|
||||
assignText(self.leIssueNum, md.issue)
|
||||
assignText(self.leIssueCount, md.issueCount)
|
||||
assignText(self.leVolumeNum, md.volume)
|
||||
assignText(self.leVolumeCount, md.volumeCount)
|
||||
assignText(self.leTitle, md.title)
|
||||
assignText(self.lePublisher, md.publisher)
|
||||
assignText(self.lePubMonth, md.month)
|
||||
assignText(self.lePubYear, md.year)
|
||||
assignText(self.leGenre, md.genre)
|
||||
assignText(self.leImprint, md.imprint)
|
||||
assignText(self.teComments, md.comments)
|
||||
assignText(self.teNotes, md.notes)
|
||||
assignText(self.leSeries, md.series)
|
||||
assignText(self.leIssueNum, md.issue)
|
||||
assignText(self.leIssueCount, md.issueCount)
|
||||
assignText(self.leVolumeNum, md.volume)
|
||||
assignText(self.leVolumeCount, md.volumeCount)
|
||||
assignText(self.leTitle, md.title)
|
||||
assignText(self.lePublisher, md.publisher)
|
||||
assignText(self.lePubMonth, md.month)
|
||||
assignText(self.lePubYear, md.year)
|
||||
assignText(self.leGenre, md.genre)
|
||||
assignText(self.leImprint, md.imprint)
|
||||
assignText(self.teComments, md.comments)
|
||||
assignText(self.teNotes, md.notes)
|
||||
assignText(self.leCriticalRating, md.criticalRating)
|
||||
assignText(self.leStoryArc, md.storyArc)
|
||||
assignText(self.leScanInfo, md.scanInfo)
|
||||
assignText(self.leSeriesGroup, md.seriesGroup)
|
||||
assignText(self.leAltSeries, md.alternateSeries)
|
||||
assignText(self.leAltIssueNum, md.alternateNumber)
|
||||
assignText(self.leStoryArc, md.storyArc)
|
||||
assignText(self.leScanInfo, md.scanInfo)
|
||||
assignText(self.leSeriesGroup, md.seriesGroup)
|
||||
assignText(self.leAltSeries, md.alternateSeries)
|
||||
assignText(self.leAltIssueNum, md.alternateNumber)
|
||||
assignText(self.leAltIssueCount, md.alternateCount)
|
||||
assignText(self.leWebLink, md.webLink)
|
||||
assignText(self.teCharacters, md.characters)
|
||||
assignText(self.teTeams, md.teams)
|
||||
assignText(self.teLocations, md.locations)
|
||||
assignText(self.leWebLink, md.webLink)
|
||||
assignText(self.teCharacters, md.characters)
|
||||
assignText(self.teTeams, md.teams)
|
||||
assignText(self.teLocations, md.locations)
|
||||
|
||||
if md.format is not None and md.format != "":
|
||||
i = self.cbFormat.findText(md.format)
|
||||
@ -827,7 +828,7 @@ class TaggerWindow(QtGui.QMainWindow):
|
||||
continue
|
||||
|
||||
self.addNewCreditEntry(row, credit['role'].title(), credit[
|
||||
'person'], (credit['primary'] if credit.has_key('primary') else False))
|
||||
'person'], (credit['primary'] if 'primary' in credit else False))
|
||||
|
||||
row += 1
|
||||
|
||||
@ -918,7 +919,7 @@ class TaggerWindow(QtGui.QMainWindow):
|
||||
|
||||
# Make a list from the coma delimited tags string
|
||||
tmp = xlate(self.teTags.toPlainText(), "str")
|
||||
if tmp != None:
|
||||
if tmp is not None:
|
||||
def striplist(l):
|
||||
return([x.strip() for x in l])
|
||||
|
||||
@ -1131,7 +1132,8 @@ class TaggerWindow(QtGui.QMainWindow):
|
||||
# loop over credit table, mark selected rows
|
||||
r = 0
|
||||
while r < self.twCredits.rowCount():
|
||||
if str(self.twCredits.item(r, 1).text()).lower() not in cix_credits:
|
||||
if str(self.twCredits.item(r, 1).text()
|
||||
).lower() not in cix_credits:
|
||||
self.twCredits.item(
|
||||
r, 1).setBackgroundColor(inactive_color)
|
||||
else:
|
||||
@ -1174,18 +1176,18 @@ class TaggerWindow(QtGui.QMainWindow):
|
||||
if enable:
|
||||
item.setPalette(active_palette)
|
||||
item.setAutoFillBackground(False)
|
||||
if type(item) == QtGui.QCheckBox:
|
||||
if isinstance(item, QtGui.QCheckBox):
|
||||
item.setEnabled(True)
|
||||
elif type(item) == QtGui.QComboBox:
|
||||
elif isinstance(item, QtGui.QComboBox):
|
||||
item.setEnabled(True)
|
||||
else:
|
||||
item.setReadOnly(False)
|
||||
else:
|
||||
item.setAutoFillBackground(True)
|
||||
if type(item) == QtGui.QCheckBox:
|
||||
if isinstance(item, QtGui.QCheckBox):
|
||||
item.setPalette(inactive_palette2)
|
||||
item.setEnabled(False)
|
||||
elif type(item) == QtGui.QComboBox:
|
||||
elif isinstance(item, QtGui.QComboBox):
|
||||
item.setPalette(inactive_palette3)
|
||||
item.setEnabled(False)
|
||||
else:
|
||||
@ -1628,7 +1630,7 @@ class TaggerWindow(QtGui.QMainWindow):
|
||||
comicVine = ComicVineTalker()
|
||||
comicVine.wait_for_rate_limit = self.settings.wait_and_retry_on_rate_limit
|
||||
cv_md = comicVine.fetchIssueData(
|
||||
match['volume_id'], match['issue_number'], self.settings)
|
||||
match['volume_id'], match['issue_number'], self.settings)
|
||||
except ComicVineTalkerException:
|
||||
print("Network error while getting issue details. Save aborted")
|
||||
|
||||
@ -2028,7 +2030,7 @@ class TaggerWindow(QtGui.QMainWindow):
|
||||
if len(byteArray) > 0:
|
||||
obj = pickle.loads(byteArray)
|
||||
localSocket.disconnectFromServer()
|
||||
if type(obj) is list:
|
||||
if isinstance(obj, list):
|
||||
self.fileSelectionList.addPathList(obj)
|
||||
else:
|
||||
# print(localSocket.errorString().toLatin1())
|
||||
@ -2053,7 +2055,7 @@ class TaggerWindow(QtGui.QMainWindow):
|
||||
# mark it "always on top", just for a moment, to force it to
|
||||
# the top
|
||||
win32gui.SetWindowPos(
|
||||
hwnd, win32con.HWND_TOPMOST, x, y, w, h, 0)
|
||||
hwnd, win32con.HWND_TOPMOST, x, y, w, h, 0)
|
||||
win32gui.SetWindowPos(
|
||||
hwnd, win32con.HWND_NOTOPMOST, x, y, w, h, 0)
|
||||
except Exception as e:
|
||||
|
@ -58,20 +58,20 @@ def get_recursive_filelist(pathlist):
|
||||
filelist = []
|
||||
for p in pathlist:
|
||||
# if path is a folder, walk it recursivly, and all files underneath
|
||||
if type(p) == str:
|
||||
if isinstance(p, str):
|
||||
# make sure string is unicode
|
||||
p = p.decode(filename_encoding) # , 'replace')
|
||||
elif type(p) != unicode:
|
||||
elif not isinstance(p, unicode):
|
||||
# it's probably a QString
|
||||
p = unicode(p)
|
||||
|
||||
if os.path.isdir(p):
|
||||
for root, dirs, files in os.walk(p):
|
||||
for f in files:
|
||||
if type(f) == str:
|
||||
if isinstance(f, str):
|
||||
# make sure string is unicode
|
||||
f = f.decode(filename_encoding, 'replace')
|
||||
elif type(f) != unicode:
|
||||
elif not isinstance(f, unicode):
|
||||
# it's probably a QString
|
||||
f = unicode(f)
|
||||
filelist.append(os.path.join(root, f))
|
||||
@ -151,7 +151,7 @@ def unique_file(file_name):
|
||||
counter = 1
|
||||
# returns ('/path/file', '.ext')
|
||||
file_name_parts = os.path.splitext(file_name)
|
||||
while 1:
|
||||
while True:
|
||||
if not os.path.lexists(file_name):
|
||||
return file_name
|
||||
file_name = file_name_parts[
|
||||
@ -591,7 +591,7 @@ def getLanguageDict():
|
||||
|
||||
|
||||
def getLanguageFromISO(iso):
|
||||
if iso == None:
|
||||
if iso is None:
|
||||
return None
|
||||
else:
|
||||
return lang_dict[iso]
|
||||
|
@ -93,7 +93,8 @@ class IdentifyThread(QtCore.QThread):
|
||||
|
||||
class VolumeSelectionWindow(QtGui.QDialog):
|
||||
|
||||
def __init__(self, parent, series_name, issue_number, year, issue_count, cover_index_list, comic_archive, settings, autoselect=False):
|
||||
def __init__(self, parent, series_name, issue_number, year, issue_count,
|
||||
cover_index_list, comic_archive, settings, autoselect=False):
|
||||
super(VolumeSelectionWindow, self).__init__(parent)
|
||||
|
||||
uic.loadUi(
|
||||
@ -135,7 +136,8 @@ class VolumeSelectionWindow(QtGui.QDialog):
|
||||
self.twList.selectRow(0)
|
||||
|
||||
def updateButtons(self):
|
||||
if self.cv_search_results is not None and len(self.cv_search_results) > 0:
|
||||
if self.cv_search_results is not None and len(
|
||||
self.cv_search_results) > 0:
|
||||
enabled = True
|
||||
else:
|
||||
enabled = False
|
||||
|
@ -44,7 +44,8 @@ def main():
|
||||
|
||||
# sort the list by series+issue+year, to put all the dupes together
|
||||
def makeKey(x):
|
||||
return "<" + unicode(x[1].series) + u" #" + unicode(x[1].issue) + u" - " + unicode(x[1].year) + ">"
|
||||
return "<" + unicode(x[1].series) + u" #" + \
|
||||
unicode(x[1].issue) + u" - " + unicode(x[1].year) + ">"
|
||||
comic_list.sort(key=makeKey, reverse=False)
|
||||
|
||||
# look for duplicate blocks
|
||||
|
@ -57,7 +57,7 @@ def main():
|
||||
md = ca.readMetadata(style)
|
||||
if len(md.pages) != 0:
|
||||
for p in md.pages:
|
||||
if p.has_key('Type') and p['Type'] in unwanted_types:
|
||||
if 'Type' in p and p['Type'] in unwanted_types:
|
||||
# This one has pages to remove. add to list!
|
||||
modify_list.append((filename, md))
|
||||
break
|
||||
@ -77,7 +77,8 @@ def main():
|
||||
if not os.access(filename, os.W_OK):
|
||||
print "Can't move: {0}: skipped!".format(filename)
|
||||
continue
|
||||
if not os.path.exists(curr_subfolder) and not os.access(curr_folder, os.W_OK):
|
||||
if not os.path.exists(curr_subfolder) and not os.access(
|
||||
curr_folder, os.W_OK):
|
||||
print "Can't create subfolder here: {0}: skipped!".format(filename)
|
||||
continue
|
||||
if not os.path.exists(curr_subfolder):
|
||||
@ -98,7 +99,7 @@ def main():
|
||||
new_num = 0
|
||||
new_pages = list()
|
||||
for p in md.pages:
|
||||
if p.has_key('Type') and p['Type'] in unwanted_types:
|
||||
if 'Type' in p and p['Type'] in unwanted_types:
|
||||
continue
|
||||
else:
|
||||
pageNum = int(p['Image'])
|
||||
@ -115,7 +116,7 @@ def main():
|
||||
# create new page entry
|
||||
new_p = dict()
|
||||
new_p['Image'] = str(new_num)
|
||||
if p.has_key('Type'):
|
||||
if 'Type' in p:
|
||||
new_p['Type'] = p['Type']
|
||||
new_pages.append(new_p)
|
||||
new_num += 1
|
||||
|
@ -101,7 +101,8 @@ def main():
|
||||
if not os.access(filename, os.W_OK):
|
||||
print "Can't move: {0}: skipped!".format(filename)
|
||||
continue
|
||||
if not os.path.exists(curr_subfolder) and not os.access(curr_folder, os.W_OK):
|
||||
if not os.path.exists(curr_subfolder) and not os.access(
|
||||
curr_folder, os.W_OK):
|
||||
print "Can't create subfolder here: {0}: skipped!".format(filename)
|
||||
continue
|
||||
if not os.path.exists(curr_subfolder):
|
||||
|
Loading…
Reference in New Issue
Block a user