mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
IGN:seriescmp cleanup
This commit is contained in:
parent
a190faea9c
commit
4865f55e40
@ -323,17 +323,16 @@ class ResultCache(SearchQueryParser):
|
|||||||
|
|
||||||
def seriescmp(self, x, y):
|
def seriescmp(self, x, y):
|
||||||
try:
|
try:
|
||||||
ans = cmp(self._data[x][9].lower(), self._data[y][9].lower()) if str else\
|
ans = cmp(self._data[x][9].lower(), self._data[y][9].lower())
|
||||||
cmp(self._data[x][9], self._data[y][9])
|
|
||||||
except AttributeError: # Some entries may be None
|
except AttributeError: # Some entries may be None
|
||||||
ans = cmp(self._data[x][9], self._data[y][9])
|
ans = cmp(self._data[x][9], self._data[y][9])
|
||||||
if ans != 0: return ans
|
if ans != 0: return ans
|
||||||
return cmp(self._data[x][10], self._data[y][10])
|
return cmp(self._data[x][10], self._data[y][10])
|
||||||
|
|
||||||
def cmp(self, loc, x, y, str=True, subsort=False):
|
def cmp(self, loc, x, y, asstr=True, subsort=False):
|
||||||
try:
|
try:
|
||||||
ans = cmp(self._data[x][loc].lower(), self._data[y][loc].lower()) if str else\
|
ans = cmp(self._data[x][loc].lower(), self._data[y][loc].lower()) if \
|
||||||
cmp(self._data[x][loc], self._data[y][loc])
|
asstr else cmp(self._data[x][loc], self._data[y][loc])
|
||||||
except AttributeError: # Some entries may be None
|
except AttributeError: # Some entries may be None
|
||||||
ans = cmp(self._data[x][loc], self._data[y][loc])
|
ans = cmp(self._data[x][loc], self._data[y][loc])
|
||||||
if subsort and ans == 0:
|
if subsort and ans == 0:
|
||||||
@ -352,7 +351,7 @@ class ResultCache(SearchQueryParser):
|
|||||||
self.first_sort = False
|
self.first_sort = False
|
||||||
fcmp = self.seriescmp if field == 'series' else \
|
fcmp = self.seriescmp if field == 'series' else \
|
||||||
functools.partial(self.cmp, FIELD_MAP[field], subsort=subsort,
|
functools.partial(self.cmp, FIELD_MAP[field], subsort=subsort,
|
||||||
str=field not in ('size', 'rating', 'timestamp'))
|
asstr=field not in ('size', 'rating', 'timestamp'))
|
||||||
|
|
||||||
self._map.sort(cmp=fcmp, reverse=not ascending)
|
self._map.sort(cmp=fcmp, reverse=not ascending)
|
||||||
self._map_filtered = [id for id in self._map if id in self._map_filtered]
|
self._map_filtered = [id for id in self._map if id in self._map_filtered]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user