mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 10:44:09 -04:00
py3: fix dict.keys() usage
micro-optimize: if r.keys() is empty, r is empty first.
This commit is contained in:
parent
d0844e8bbe
commit
f915f11a0c
@ -14,6 +14,7 @@ from calibre.ebooks.metadata import string_to_authors, MetaInformation
|
|||||||
from calibre.utils.logging import default_log
|
from calibre.utils.logging import default_log
|
||||||
from calibre.ptempfile import TemporaryFile
|
from calibre.ptempfile import TemporaryFile
|
||||||
from calibre import force_unicode
|
from calibre import force_unicode
|
||||||
|
from polyglot.builtins import iterkeys
|
||||||
|
|
||||||
|
|
||||||
def _clean(s):
|
def _clean(s):
|
||||||
@ -110,9 +111,8 @@ def _get_cover(soup, rdr):
|
|||||||
except:
|
except:
|
||||||
# Probably invalid width, height aattributes, ignore
|
# Probably invalid width, height aattributes, ignore
|
||||||
continue
|
continue
|
||||||
l = r.keys()
|
if r:
|
||||||
l.sort()
|
l = sorted(iterkeys(r))
|
||||||
if l:
|
|
||||||
ans = r[l[0]]
|
ans = r[l[0]]
|
||||||
# this link comes from the internal html, which is in a subdir
|
# this link comes from the internal html, which is in a subdir
|
||||||
if ans is not None:
|
if ans is not None:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user