mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix various warnings from running updated pyflakes on the entire codebase
This commit is contained in:
parent
d425bcceca
commit
e49227ee40
@ -124,5 +124,5 @@ class CIO_Magazine(BasicNewsRecipe):
|
|||||||
dict(title=title, url=url, date=pubdate,
|
dict(title=title, url=url, date=pubdate,
|
||||||
description=description,
|
description=description,
|
||||||
content=''))
|
content=''))
|
||||||
feeds = [(key, articles[key]) for key in feeds if articles.has_key(key)]
|
feeds = [(k, articles[k]) for k in feeds if articles.has_key(k)]
|
||||||
return feeds
|
return feeds
|
||||||
|
@ -114,5 +114,5 @@ class ElDiplo_Recipe(BasicNewsRecipe):
|
|||||||
articles[section].append(dict(title=title,author=auth,url=url,date=None,description=description,content=''))
|
articles[section].append(dict(title=title,author=auth,url=url,date=None,description=description,content=''))
|
||||||
|
|
||||||
#ans = self.sort_index_by(ans, {'The Front Page':-1, 'Dining In, Dining Out':1, 'Obituaries':2})
|
#ans = self.sort_index_by(ans, {'The Front Page':-1, 'Dining In, Dining Out':1, 'Obituaries':2})
|
||||||
ans = [(section, articles[section]) for section in ans if articles.has_key(section)]
|
ans = [(s, articles[s]) for s in ans if articles.has_key(s)]
|
||||||
return ans
|
return ans
|
||||||
|
@ -80,7 +80,7 @@ class ModorosBlogHu(BasicNewsRecipe):
|
|||||||
for h in cur_items:
|
for h in cur_items:
|
||||||
f.write(h+'\n')
|
f.write(h+'\n')
|
||||||
|
|
||||||
remove = [f for f in feeds if len(f) == 0 and
|
remove = [fl for fl in feeds if len(fl) == 0 and
|
||||||
self.remove_empty_feeds]
|
self.remove_empty_feeds]
|
||||||
for f in remove:
|
for f in remove:
|
||||||
feeds.remove(f)
|
feeds.remove(f)
|
||||||
|
@ -100,7 +100,7 @@ class OfficeSpaceBlogHu(BasicNewsRecipe):
|
|||||||
for h in cur_items:
|
for h in cur_items:
|
||||||
f.write(h+'\n')
|
f.write(h+'\n')
|
||||||
|
|
||||||
remove = [f for f in feeds if len(f) == 0 and
|
remove = [fl for fl in feeds if len(fl) == 0 and
|
||||||
self.remove_empty_feeds]
|
self.remove_empty_feeds]
|
||||||
for f in remove:
|
for f in remove:
|
||||||
feeds.remove(f)
|
feeds.remove(f)
|
||||||
|
@ -46,5 +46,5 @@ class NYTimes(BasicNewsRecipe):
|
|||||||
if feed not in articles:
|
if feed not in articles:
|
||||||
articles[feed] = []
|
articles[feed] = []
|
||||||
articles[feed].append(dict(title=title, url=url, date=pubdate,description=description,content=''))
|
articles[feed].append(dict(title=title, url=url, date=pubdate,description=description,content=''))
|
||||||
ans = [(key, articles[key]) for key in articles.keys()]
|
ans = [(keyl, articles[keyl]) for keyl in articles.keys()]
|
||||||
return ans
|
return ans
|
||||||
|
@ -216,5 +216,5 @@ class CanWestPaper(BasicNewsRecipe):
|
|||||||
articles[key] = []
|
articles[key] = []
|
||||||
articles[key].append(dict(title=title,url=url,date=pubdate,description=description,author=author,content=''))
|
articles[key].append(dict(title=title,url=url,date=pubdate,description=description,author=author,content=''))
|
||||||
|
|
||||||
ans = [(key, articles[key]) for key in ans if articles.has_key(key)]
|
ans = [(keyl, articles[keyl]) for keyl in ans if articles.has_key(keyl)]
|
||||||
return ans
|
return ans
|
||||||
|
@ -216,5 +216,5 @@ class CanWestPaper(BasicNewsRecipe):
|
|||||||
articles[key] = []
|
articles[key] = []
|
||||||
articles[key].append(dict(title=title,url=url,date=pubdate,description=description,author=author,content=''))
|
articles[key].append(dict(title=title,url=url,date=pubdate,description=description,author=author,content=''))
|
||||||
|
|
||||||
ans = [(key, articles[key]) for key in ans if articles.has_key(key)]
|
ans = [(k, articles[k]) for k in ans if articles.has_key(k)]
|
||||||
return ans
|
return ans
|
||||||
|
@ -102,5 +102,5 @@ class CanWestPaper(BasicNewsRecipe):
|
|||||||
articles[key] = []
|
articles[key] = []
|
||||||
articles[key].append(dict(title=title,url=url,date=pubdate,description=description,author=author,content=''))
|
articles[key].append(dict(title=title,url=url,date=pubdate,description=description,author=author,content=''))
|
||||||
|
|
||||||
ans = [(key, articles[key]) for key in ans if articles.has_key(key)]
|
ans = [(keyl, articles[key]) for keyl in ans if articles.has_key(keyl)]
|
||||||
return ans
|
return ans
|
||||||
|
@ -217,5 +217,5 @@ class CanWestPaper(BasicNewsRecipe):
|
|||||||
articles[key] = []
|
articles[key] = []
|
||||||
articles[key].append(dict(title=title,url=url,date=pubdate,description=description,author=author,content=''))
|
articles[key].append(dict(title=title,url=url,date=pubdate,description=description,author=author,content=''))
|
||||||
|
|
||||||
ans = [(key, articles[key]) for key in ans if articles.has_key(key)]
|
ans = [(keyl, articles[keyl]) for keyl in ans if articles.has_key(keyl)]
|
||||||
return ans
|
return ans
|
||||||
|
@ -211,7 +211,7 @@ class AddRemoveTest(BaseTest):
|
|||||||
'Test removal of books'
|
'Test removal of books'
|
||||||
cl = self.cloned_library
|
cl = self.cloned_library
|
||||||
cache = self.init_cache()
|
cache = self.init_cache()
|
||||||
af, ae, at = self.assertFalse, self.assertEqual, self.assertTrue
|
af, ae = self.assertFalse, self.assertEqual
|
||||||
authors = cache.fields['authors'].table
|
authors = cache.fields['authors'].table
|
||||||
|
|
||||||
# Delete a single book, with no formats and check cleaning
|
# Delete a single book, with no formats and check cleaning
|
||||||
|
@ -285,7 +285,7 @@ class LegacyTest(BaseTest):
|
|||||||
ndb = self.init_legacy()
|
ndb = self.init_legacy()
|
||||||
db = self.init_old()
|
db = self.init_old()
|
||||||
all_ids = ndb.new_api.all_book_ids()
|
all_ids = ndb.new_api.all_book_ids()
|
||||||
op1, op2 = {'xx':'yy'}, {'yy':'zz'}
|
op1 = {'xx':'yy'}
|
||||||
for x in (
|
for x in (
|
||||||
('has_conversion_options', all_ids),
|
('has_conversion_options', all_ids),
|
||||||
('conversion_options', 1, 'PIPE'),
|
('conversion_options', 1, 'PIPE'),
|
||||||
|
@ -493,7 +493,7 @@ class ReadingTest(BaseTest):
|
|||||||
cache = self.init_cache()
|
cache = self.init_cache()
|
||||||
cache._search_api.cache = c = TestCache()
|
cache._search_api.cache = c = TestCache()
|
||||||
|
|
||||||
ae, at = self.assertEqual, self.assertTrue
|
ae = self.assertEqual
|
||||||
|
|
||||||
def test(hit, result, *args):
|
def test(hit, result, *args):
|
||||||
c.cc
|
c.cc
|
||||||
|
@ -337,7 +337,7 @@ class WritingTest(BaseTest):
|
|||||||
'Test the automatic backup of changed metadata'
|
'Test the automatic backup of changed metadata'
|
||||||
cl = self.cloned_library
|
cl = self.cloned_library
|
||||||
cache = self.init_cache(cl)
|
cache = self.init_cache(cl)
|
||||||
ae, af, sf, ff = self.assertEqual, self.assertFalse, cache.set_field, cache.field_for
|
ae, af, sf = self.assertEqual, self.assertFalse, cache.set_field
|
||||||
# First empty dirtied
|
# First empty dirtied
|
||||||
cache.dump_metadata()
|
cache.dump_metadata()
|
||||||
af(cache.dirtied_cache)
|
af(cache.dirtied_cache)
|
||||||
|
@ -720,7 +720,7 @@ class KOBO(USBMS):
|
|||||||
return book
|
return book
|
||||||
|
|
||||||
def get_device_paths(self):
|
def get_device_paths(self):
|
||||||
paths, prefixes = {}, {}
|
paths = {}
|
||||||
for prefix, path, source_id in [
|
for prefix, path, source_id in [
|
||||||
('main', 'metadata.calibre', 0),
|
('main', 'metadata.calibre', 0),
|
||||||
('card_a', 'metadata.calibre', 1),
|
('card_a', 'metadata.calibre', 1),
|
||||||
@ -1380,7 +1380,7 @@ class KOBOTOUCH(KOBO):
|
|||||||
}
|
}
|
||||||
GLO_COVER_FILE_ENDINGS = { # Glo and Aura share resolution, so the image sizes should be the same.
|
GLO_COVER_FILE_ENDINGS = { # Glo and Aura share resolution, so the image sizes should be the same.
|
||||||
' - N3_FULL.parsed':[(758,1024),0, 99,True,], # Used for screensaver, home screen
|
' - N3_FULL.parsed':[(758,1024),0, 99,True,], # Used for screensaver, home screen
|
||||||
' - N3_LIBRARY_FULL.parsed':[(355,479),0, 99,False,], # Used for Details screen before FW2.8.1, then for current book tile on home screen
|
' - N3_LIBRARY_FULL.parsed':[(355,479),0, 99,False,], # Used for Details screen before FW2.8.1, then for current book tile on home screen
|
||||||
' - N3_LIBRARY_GRID.parsed':[(149,201),0, 99,False,], # Used for library lists
|
' - N3_LIBRARY_GRID.parsed':[(149,201),0, 99,False,], # Used for library lists
|
||||||
' - AndroidBookLoadTablet_Aspect.parsed':[(355,479), 88, 99,False,], # Used for Details screen from FW2.8.1
|
' - AndroidBookLoadTablet_Aspect.parsed':[(355,479), 88, 99,False,], # Used for Details screen from FW2.8.1
|
||||||
}
|
}
|
||||||
|
@ -185,6 +185,7 @@ def cleanup_markup(log, root, styles, dest_dir, detect_cover):
|
|||||||
width, height, fmt = identify(path)
|
width, height, fmt = identify(path)
|
||||||
except:
|
except:
|
||||||
width, height, fmt = 0, 0, None
|
width, height, fmt = 0, 0, None
|
||||||
|
del fmt
|
||||||
try:
|
try:
|
||||||
is_cover = 0.8 <= height/width <= 1.8 and height*width >= 160000
|
is_cover = 0.8 <= height/width <= 1.8 and height*width >= 160000
|
||||||
except ZeroDivisionError:
|
except ZeroDivisionError:
|
||||||
|
@ -126,8 +126,8 @@ def mi_to_html(mi, field_list=None, default_author_link=None, use_roman_numbers=
|
|||||||
ans.append((field, row % (name, u', '.join(fmts))))
|
ans.append((field, row % (name, u', '.join(fmts))))
|
||||||
elif field == 'identifiers':
|
elif field == 'identifiers':
|
||||||
urls = urls_from_identifiers(mi.identifiers)
|
urls = urls_from_identifiers(mi.identifiers)
|
||||||
links = [u'<a href="%s" title="%s:%s">%s</a>' % (a(url), a(id_typ), a(id_val), p(name))
|
links = [u'<a href="%s" title="%s:%s">%s</a>' % (a(url), a(id_typ), a(id_val), p(namel))
|
||||||
for name, id_typ, id_val, url in urls]
|
for namel, id_typ, id_val, url in urls]
|
||||||
links = u', '.join(links)
|
links = u', '.join(links)
|
||||||
if links:
|
if links:
|
||||||
ans.append((field, row % (_('Ids')+':', links)))
|
ans.append((field, row % (_('Ids')+':', links)))
|
||||||
@ -189,8 +189,8 @@ def mi_to_html(mi, field_list=None, default_author_link=None, use_roman_numbers=
|
|||||||
dt = 'text'
|
dt = 'text'
|
||||||
return 'datatype_%s'%dt
|
return 'datatype_%s'%dt
|
||||||
|
|
||||||
ans = [u'<tr id="%s" class="%s">%s</tr>'%(field.replace('#', '_'),
|
ans = [u'<tr id="%s" class="%s">%s</tr>'%(fieldl.replace('#', '_'),
|
||||||
classname(field), html) for field, html in ans]
|
classname(fieldl), html) for fieldl, html in ans]
|
||||||
# print '\n'.join(ans)
|
# print '\n'.join(ans)
|
||||||
return u'<table class="fields">%s</table>'%(u'\n'.join(ans)), comment_fields
|
return u'<table class="fields">%s</table>'%(u'\n'.join(ans)), comment_fields
|
||||||
|
|
||||||
|
@ -23,13 +23,15 @@ def get_metadata(stream):
|
|||||||
while 1:
|
while 1:
|
||||||
data = stream.read(1)
|
data = stream.read(1)
|
||||||
if data == '\x00':
|
if data == '\x00':
|
||||||
if not skip: return result
|
if not skip:
|
||||||
|
return result
|
||||||
skip -= 1
|
skip -= 1
|
||||||
result, data = '', ''
|
result, data = '', ''
|
||||||
result += data
|
result += data
|
||||||
|
|
||||||
stream.read(38) # skip past some uninteresting headers
|
stream.read(38) # skip past some uninteresting headers
|
||||||
_, category, title, author = cString(), cString(), cString(1), cString(2)
|
cString()
|
||||||
|
category, title, author = cString(), cString(1), cString(2)
|
||||||
|
|
||||||
if title:
|
if title:
|
||||||
mi.title = title
|
mi.title = title
|
||||||
|
@ -299,8 +299,8 @@ class Edelweiss(Source):
|
|||||||
if not entries:
|
if not entries:
|
||||||
return
|
return
|
||||||
|
|
||||||
workers = [Worker(sku, url, i, result_queue, br.clone_browser(), timeout, log, self)
|
workers = [Worker(skul, url, i, result_queue, br.clone_browser(), timeout, log, self)
|
||||||
for i, (url, sku) in enumerate(entries[:5])]
|
for i, (url, skul) in enumerate(entries[:5])]
|
||||||
|
|
||||||
for w in workers:
|
for w in workers:
|
||||||
w.start()
|
w.start()
|
||||||
|
@ -120,8 +120,8 @@ def embed_all_fonts(container, stats, report):
|
|||||||
|
|
||||||
# Write out CSS
|
# Write out CSS
|
||||||
rules = [';\n\t'.join('%s: %s' % (
|
rules = [';\n\t'.join('%s: %s' % (
|
||||||
k, '"%s"' % v if k == 'font-family' else v) for k, v in rule.iteritems() if (k in props and props[k] != v and v != '400') or k == 'src')
|
k, '"%s"' % v if k == 'font-family' else v) for k, v in rulel.iteritems() if (k in props and props[k] != v and v != '400') or k == 'src')
|
||||||
for rule in rules]
|
for rulel in rules]
|
||||||
css = '\n\n'.join(['@font-face {\n\t%s\n}' % r for r in rules])
|
css = '\n\n'.join(['@font-face {\n\t%s\n}' % r for r in rules])
|
||||||
item = container.generate_item('fonts.css', id_prefix='font_embed')
|
item = container.generate_item('fonts.css', id_prefix='font_embed')
|
||||||
name = container.href_to_name(item.get('href'), container.opf_name)
|
name = container.href_to_name(item.get('href'), container.opf_name)
|
||||||
|
@ -231,7 +231,7 @@ class AutoAdder(QObject):
|
|||||||
paths.extend(p)
|
paths.extend(p)
|
||||||
formats.extend(f)
|
formats.extend(f)
|
||||||
metadata.extend(mis)
|
metadata.extend(mis)
|
||||||
dups = [(mi, mi.cover, [p]) for mi, p in zip(metadata, paths)]
|
dups = [(mic, mic.cover, [p]) for mic, p in zip(metadata, paths)]
|
||||||
d = DuplicatesQuestion(m.db, dups, parent=gui)
|
d = DuplicatesQuestion(m.db, dups, parent=gui)
|
||||||
dups = tuple(d.duplicates)
|
dups = tuple(d.duplicates)
|
||||||
if dups:
|
if dups:
|
||||||
|
@ -16,9 +16,9 @@ class PluginWidget(QWidget, Ui_Form):
|
|||||||
TITLE = _('BibTeX Options')
|
TITLE = _('BibTeX Options')
|
||||||
HELP = _('Options specific to')+' BibTeX '+_('output')
|
HELP = _('Options specific to')+' BibTeX '+_('output')
|
||||||
OPTION_FIELDS = [('bib_cit','{authors}{id}'),
|
OPTION_FIELDS = [('bib_cit','{authors}{id}'),
|
||||||
('bib_entry', 0), #mixed
|
('bib_entry', 0), # mixed
|
||||||
('bibfile_enc', 0), #utf-8
|
('bibfile_enc', 0), # utf-8
|
||||||
('bibfile_enctag', 0), #strict
|
('bibfile_enctag', 0), # strict
|
||||||
('impcit', True),
|
('impcit', True),
|
||||||
('addfiles', False),
|
('addfiles', False),
|
||||||
]
|
]
|
||||||
@ -30,16 +30,16 @@ class PluginWidget(QWidget, Ui_Form):
|
|||||||
QWidget.__init__(self, parent)
|
QWidget.__init__(self, parent)
|
||||||
self.setupUi(self)
|
self.setupUi(self)
|
||||||
|
|
||||||
def initialize(self, name, db): #not working properly to update
|
def initialize(self, name, db): # not working properly to update
|
||||||
from calibre.library.catalogs import FIELDS
|
from calibre.library.catalogs import FIELDS
|
||||||
|
|
||||||
self.all_fields = [x for x in FIELDS if x != 'all']
|
self.all_fields = [x for x in FIELDS if x != 'all']
|
||||||
#add custom columns
|
# add custom columns
|
||||||
for x in sorted(db.custom_field_keys()):
|
for x in sorted(db.custom_field_keys()):
|
||||||
self.all_fields.append(x)
|
self.all_fields.append(x)
|
||||||
if db.field_metadata[x]['datatype'] == 'series':
|
if db.field_metadata[x]['datatype'] == 'series':
|
||||||
self.all_fields.append(x+'_index')
|
self.all_fields.append(x+'_index')
|
||||||
#populate
|
# populate
|
||||||
for x in self.all_fields:
|
for x in self.all_fields:
|
||||||
QListWidgetItem(x, self.db_fields)
|
QListWidgetItem(x, self.db_fields)
|
||||||
|
|
||||||
@ -78,7 +78,7 @@ class PluginWidget(QWidget, Ui_Form):
|
|||||||
|
|
||||||
# Dictionary currently activated fields
|
# Dictionary currently activated fields
|
||||||
if len(self.db_fields.selectedItems()):
|
if len(self.db_fields.selectedItems()):
|
||||||
opts_dict = {'fields':[unicode(item.text()) for item in self.db_fields.selectedItems()]}
|
opts_dict = {'fields':[unicode(i.text()) for i in self.db_fields.selectedItems()]}
|
||||||
else:
|
else:
|
||||||
opts_dict = {'fields':['all']}
|
opts_dict = {'fields':['all']}
|
||||||
|
|
||||||
|
@ -56,6 +56,6 @@ class PluginWidget(QWidget, Ui_Form):
|
|||||||
|
|
||||||
# Return a dictionary with current options for this widget
|
# Return a dictionary with current options for this widget
|
||||||
if len(self.db_fields.selectedItems()):
|
if len(self.db_fields.selectedItems()):
|
||||||
return {'fields':[unicode(item.text()) for item in self.db_fields.selectedItems()]}
|
return {'fields':[unicode(i.text()) for i in self.db_fields.selectedItems()]}
|
||||||
else:
|
else:
|
||||||
return {'fields':['all']}
|
return {'fields':['all']}
|
||||||
|
@ -200,11 +200,11 @@ def dnd_get_image(md, image_exts=IMAGE_EXTENSIONS):
|
|||||||
md.urls()]
|
md.urls()]
|
||||||
purls = [urlparse(u) for u in urls]
|
purls = [urlparse(u) for u in urls]
|
||||||
# First look for a local file
|
# First look for a local file
|
||||||
images = [u2p(x) for x in purls if x.scheme in ('', 'file')]
|
images = [u2p(xu) for xu in purls if xu.scheme in ('', 'file')]
|
||||||
images = [x for x in images if
|
images = [xi for xi in images if
|
||||||
posixpath.splitext(urllib.unquote(x))[1][1:].lower() in
|
posixpath.splitext(urllib.unquote(xi))[1][1:].lower() in
|
||||||
image_exts]
|
image_exts]
|
||||||
images = [x for x in images if os.path.exists(x)]
|
images = [xi for xi in images if os.path.exists(xi)]
|
||||||
p = QPixmap()
|
p = QPixmap()
|
||||||
for path in images:
|
for path in images:
|
||||||
try:
|
try:
|
||||||
@ -223,8 +223,8 @@ def dnd_get_image(md, image_exts=IMAGE_EXTENSIONS):
|
|||||||
if rurl and fname:
|
if rurl and fname:
|
||||||
return rurl, fname
|
return rurl, fname
|
||||||
# Look through all remaining URLs
|
# Look through all remaining URLs
|
||||||
remote_urls = [x for x in purls if x.scheme in ('http', 'https',
|
remote_urls = [xu for xu in purls if xu.scheme in ('http', 'https',
|
||||||
'ftp') and posixpath.splitext(x.path)[1][1:].lower() in image_exts]
|
'ftp') and posixpath.splitext(xu.path)[1][1:].lower() in image_exts]
|
||||||
if remote_urls:
|
if remote_urls:
|
||||||
rurl = remote_urls[0]
|
rurl = remote_urls[0]
|
||||||
fname = posixpath.basename(urllib.unquote(rurl.path))
|
fname = posixpath.basename(urllib.unquote(rurl.path))
|
||||||
|
@ -763,7 +763,7 @@ class FormatsManager(QWidget):
|
|||||||
db.add_format(id_, ext, spool, notify=False,
|
db.add_format(id_, ext, spool, notify=False,
|
||||||
index_is_id=True)
|
index_is_id=True)
|
||||||
dbfmts = db.formats(id_, index_is_id=True)
|
dbfmts = db.formats(id_, index_is_id=True)
|
||||||
db_extensions = set([f.lower() for f in (dbfmts.split(',') if dbfmts
|
db_extensions = set([fl.lower() for fl in (dbfmts.split(',') if dbfmts
|
||||||
else [])])
|
else [])])
|
||||||
extensions = new_extensions.union(old_extensions)
|
extensions = new_extensions.union(old_extensions)
|
||||||
for ext in db_extensions:
|
for ext in db_extensions:
|
||||||
@ -1310,7 +1310,7 @@ class IdentifiersEdit(QLineEdit): # {{{
|
|||||||
if v is not None:
|
if v is not None:
|
||||||
val[k] = v
|
val[k] = v
|
||||||
ids = sorted(val.iteritems(), key=keygen)
|
ids = sorted(val.iteritems(), key=keygen)
|
||||||
txt = ', '.join(['%s:%s'%(k.lower(), v) for k, v in ids])
|
txt = ', '.join(['%s:%s'%(k.lower(), vl) for k, vl in ids])
|
||||||
# Use clear + insert instead of setText so that undo works
|
# Use clear + insert instead of setText so that undo works
|
||||||
self.clear()
|
self.clear()
|
||||||
self.insert(txt.strip())
|
self.insert(txt.strip())
|
||||||
|
@ -148,7 +148,7 @@ class Matches(QAbstractItemModel):
|
|||||||
def setData(self, index, data, role):
|
def setData(self, index, data, role):
|
||||||
if not index.isValid():
|
if not index.isValid():
|
||||||
return False
|
return False
|
||||||
row, col = index.row(), index.column()
|
col = index.column()
|
||||||
if col == 0:
|
if col == 0:
|
||||||
if data.toBool():
|
if data.toBool():
|
||||||
enable_plugin(self.get_plugin(index))
|
enable_plugin(self.get_plugin(index))
|
||||||
@ -225,7 +225,7 @@ class SearchFilter(SearchQueryParser):
|
|||||||
elif query.startswith('~'):
|
elif query.startswith('~'):
|
||||||
matchkind = REGEXP_MATCH
|
matchkind = REGEXP_MATCH
|
||||||
query = query[1:]
|
query = query[1:]
|
||||||
if matchkind != REGEXP_MATCH: ### leave case in regexps because it can be significant e.g. \S \W \D
|
if matchkind != REGEXP_MATCH: # leave case in regexps because it can be significant e.g. \S \W \D
|
||||||
query = query.lower()
|
query = query.lower()
|
||||||
|
|
||||||
if location not in self.USABLE_LOCATIONS:
|
if location not in self.USABLE_LOCATIONS:
|
||||||
@ -265,9 +265,9 @@ class SearchFilter(SearchQueryParser):
|
|||||||
if locvalue in ('affiliate', 'drm', 'enabled'):
|
if locvalue in ('affiliate', 'drm', 'enabled'):
|
||||||
continue
|
continue
|
||||||
try:
|
try:
|
||||||
### Can't separate authors because comma is used for name sep and author sep
|
# Can't separate authors because comma is used for name sep and author sep
|
||||||
### Exact match might not get what you want. For that reason, turn author
|
# Exact match might not get what you want. For that reason, turn author
|
||||||
### exactmatch searches into contains searches.
|
# exactmatch searches into contains searches.
|
||||||
if locvalue == 'name' and matchkind == EQUALS_MATCH:
|
if locvalue == 'name' and matchkind == EQUALS_MATCH:
|
||||||
m = CONTAINS_MATCH
|
m = CONTAINS_MATCH
|
||||||
else:
|
else:
|
||||||
@ -280,7 +280,7 @@ class SearchFilter(SearchQueryParser):
|
|||||||
if _match(query, vals, m, use_primary_find_in_search=upf):
|
if _match(query, vals, m, use_primary_find_in_search=upf):
|
||||||
matches.add(sr)
|
matches.add(sr)
|
||||||
break
|
break
|
||||||
except ValueError: # Unicode errors
|
except ValueError: # Unicode errors
|
||||||
import traceback
|
import traceback
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
return matches
|
return matches
|
||||||
|
@ -115,7 +115,7 @@ def get_decoded_raw(name):
|
|||||||
enc = force_encoding(raw, verbose=True)
|
enc = force_encoding(raw, verbose=True)
|
||||||
try:
|
try:
|
||||||
raw = raw.decode(enc)
|
raw = raw.decode(enc)
|
||||||
except ValueError:
|
except (LookupError, ValueError):
|
||||||
pass
|
pass
|
||||||
return raw, syntax
|
return raw, syntax
|
||||||
|
|
||||||
|
@ -636,7 +636,7 @@ class DiffSplit(QSplitter): # {{{
|
|||||||
for x, val in v.line_number_map.iteritems():
|
for x, val in v.line_number_map.iteritems():
|
||||||
dict.__setitem__(lnm, mapnum(x), val)
|
dict.__setitem__(lnm, mapnum(x), val)
|
||||||
v.line_number_map = lnm
|
v.line_number_map = lnm
|
||||||
v.changes = [(mapnum(t), mapnum(b), kind) for t, b, kind in v.changes]
|
v.changes = [(mapnum(t), mapnum(b), k) for t, b, k in v.changes]
|
||||||
v.headers = [(mapnum(x), name) for x, name in v.headers]
|
v.headers = [(mapnum(x), name) for x, name in v.headers]
|
||||||
v.images = OrderedDict((mapnum(x), v) for x, v in v.images.iteritems())
|
v.images = OrderedDict((mapnum(x), v) for x, v in v.images.iteritems())
|
||||||
v.viewport().update()
|
v.viewport().update()
|
||||||
@ -826,7 +826,6 @@ class DiffSplit(QSplitter): # {{{
|
|||||||
self.replace_helper(alo, best_i, blo, best_j)
|
self.replace_helper(alo, best_i, blo, best_j)
|
||||||
|
|
||||||
# do intraline marking on the synch pair
|
# do intraline marking on the synch pair
|
||||||
aelt, belt = a[best_i], b[best_j]
|
|
||||||
if eqi is None:
|
if eqi is None:
|
||||||
self.do_replace(best_i, best_i+1, best_j, best_j+1)
|
self.do_replace(best_i, best_i+1, best_j, best_j+1)
|
||||||
else:
|
else:
|
||||||
|
@ -680,7 +680,7 @@ class FileList(QTreeWidget):
|
|||||||
l.addWidget(bb)
|
l.addWidget(bb)
|
||||||
if d.exec_() == d.Accepted:
|
if d.exec_() == d.Accepted:
|
||||||
tprefs['remove_existing_links_when_linking_sheets'] = r.isChecked()
|
tprefs['remove_existing_links_when_linking_sheets'] = r.isChecked()
|
||||||
sheets = [unicode(s.item(i).text()) for i in xrange(s.count()) if s.item(i).checkState() == Qt.Checked]
|
sheets = [unicode(s.item(il).text()) for il in xrange(s.count()) if s.item(il).checkState() == Qt.Checked]
|
||||||
if sheets:
|
if sheets:
|
||||||
self.link_stylesheets_requested.emit(names, sheets, r.isChecked())
|
self.link_stylesheets_requested.emit(names, sheets, r.isChecked())
|
||||||
|
|
||||||
|
@ -282,8 +282,8 @@ class BrowseServer(object):
|
|||||||
ans = ans.replace('{Search}', _('Search'))
|
ans = ans.replace('{Search}', _('Search'))
|
||||||
opts = ['<option %svalue="%s">%s</option>' % (
|
opts = ['<option %svalue="%s">%s</option>' % (
|
||||||
'selected="selected" ' if k==sort else '',
|
'selected="selected" ' if k==sort else '',
|
||||||
xml(k), xml(n), ) for k, n in
|
xml(k), xml(nl), ) for k, nl in
|
||||||
sorted(sort_opts, key=lambda x: sort_key(operator.itemgetter(1)(x))) if k and n]
|
sorted(sort_opts, key=lambda x: sort_key(operator.itemgetter(1)(x))) if k and nl]
|
||||||
ans = ans.replace('{sort_select_options}', ('\n'+' '*20).join(opts))
|
ans = ans.replace('{sort_select_options}', ('\n'+' '*20).join(opts))
|
||||||
lp = self.db.library_path
|
lp = self.db.library_path
|
||||||
if isbytestring(lp):
|
if isbytestring(lp):
|
||||||
|
@ -764,8 +764,8 @@ class DNSOutgoing(object):
|
|||||||
self.finished = 1
|
self.finished = 1
|
||||||
for question in self.questions:
|
for question in self.questions:
|
||||||
self.writeQuestion(question)
|
self.writeQuestion(question)
|
||||||
for answer, time in self.answers:
|
for answer, atime in self.answers:
|
||||||
self.writeRecord(answer, time)
|
self.writeRecord(answer, atime)
|
||||||
for authority in self.authorities:
|
for authority in self.authorities:
|
||||||
self.writeRecord(authority, 0)
|
self.writeRecord(authority, 0)
|
||||||
for additional in self.additionals:
|
for additional in self.additionals:
|
||||||
@ -873,9 +873,9 @@ class Engine(threading.Thread):
|
|||||||
rr, wr, er = select.select(rs, [], [], self.timeout)
|
rr, wr, er = select.select(rs, [], [], self.timeout)
|
||||||
if globals()['_GLOBAL_DONE']:
|
if globals()['_GLOBAL_DONE']:
|
||||||
continue
|
continue
|
||||||
for socket in rr:
|
for sock in rr:
|
||||||
try:
|
try:
|
||||||
self.readers[socket].handle_read()
|
self.readers[sock].handle_read()
|
||||||
except:
|
except:
|
||||||
if DEBUG:
|
if DEBUG:
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
|
@ -1811,7 +1811,7 @@ Enter SQL statements terminated with a ";"
|
|||||||
identity=lambda x:x
|
identity=lambda x:x
|
||||||
for i in range(ncols):
|
for i in range(ncols):
|
||||||
if len(datas[i])>1:
|
if len(datas[i])>1:
|
||||||
raise self.Error("Column #%d \"%s\" has ambiguous data format - %s" % (i+1, header[i], ", ".join([d.__name__ for d in datas[i]])))
|
raise self.Error("Column #%d \"%s\" has ambiguous data format - %s" % (i+1, header[i], ", ".join([dl.__name__ for dl in datas[i]])))
|
||||||
if datas[i]:
|
if datas[i]:
|
||||||
datas[i]=datas[i][0]
|
datas[i]=datas[i][0]
|
||||||
else:
|
else:
|
||||||
|
@ -74,8 +74,8 @@ def save_cover_data_to(data, path, bgcolor='#ffffff', resize_to=None,
|
|||||||
fmt = normalize_format_name(fmt[1:])
|
fmt = normalize_format_name(fmt[1:])
|
||||||
|
|
||||||
if grayscale:
|
if grayscale:
|
||||||
img.type = "GrayscaleType"
|
img.type = "GrayscaleType"
|
||||||
changed = True
|
changed = True
|
||||||
|
|
||||||
if resize_to is not None:
|
if resize_to is not None:
|
||||||
img.size = (resize_to[0], resize_to[1])
|
img.size = (resize_to[0], resize_to[1])
|
||||||
@ -192,7 +192,7 @@ def _get_line(img, dw, tokens, line_width):
|
|||||||
line, rest = tokens, []
|
line, rest = tokens, []
|
||||||
while True:
|
while True:
|
||||||
m = img.font_metrics(dw, ' '.join(line))
|
m = img.font_metrics(dw, ' '.join(line))
|
||||||
width, height = m.text_width, m.text_height
|
width = m.text_width
|
||||||
if width < line_width:
|
if width < line_width:
|
||||||
return line, rest
|
return line, rest
|
||||||
rest = line[-1:] + rest
|
rest = line[-1:] + rest
|
||||||
|
@ -1601,7 +1601,7 @@ class BasicNewsRecipe(Recipe):
|
|||||||
parsed_feeds.append(feed)
|
parsed_feeds.append(feed)
|
||||||
self.log.exception(msg)
|
self.log.exception(msg)
|
||||||
|
|
||||||
remove = [f for f in parsed_feeds if len(f) == 0 and
|
remove = [fl for fl in parsed_feeds if len(fl) == 0 and
|
||||||
self.remove_empty_feeds]
|
self.remove_empty_feeds]
|
||||||
for f in remove:
|
for f in remove:
|
||||||
parsed_feeds.remove(f)
|
parsed_feeds.remove(f)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user