mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-07 10:14:46 -04:00
max_size()
This commit is contained in:
parent
a7ca60b0e9
commit
0ab4ebbfbd
@ -680,12 +680,12 @@ class LibraryDatabase(object):
|
|||||||
MT = lambda func: types.MethodType(func, None, LibraryDatabase)
|
MT = lambda func: types.MethodType(func, None, LibraryDatabase)
|
||||||
|
|
||||||
# Legacy getter API {{{
|
# Legacy getter API {{{
|
||||||
for prop in ('author_sort', 'authors', 'comment', 'comments', 'publisher',
|
for prop in ('author_sort', 'authors', 'comment', 'comments', 'publisher', 'max_size',
|
||||||
'rating', 'series', 'series_index', 'tags', 'title', 'title_sort',
|
'rating', 'series', 'series_index', 'tags', 'title', 'title_sort',
|
||||||
'timestamp', 'uuid', 'pubdate', 'ondevice', 'metadata_last_modified', 'languages',):
|
'timestamp', 'uuid', 'pubdate', 'ondevice', 'metadata_last_modified', 'languages',):
|
||||||
def getter(prop):
|
def getter(prop):
|
||||||
fm = {'comment':'comments', 'metadata_last_modified':
|
fm = {'comment':'comments', 'metadata_last_modified':
|
||||||
'last_modified', 'title_sort':'sort'}.get(prop, prop)
|
'last_modified', 'title_sort':'sort', 'max_size':'size'}.get(prop, prop)
|
||||||
def func(self, index, index_is_id=False):
|
def func(self, index, index_is_id=False):
|
||||||
return self.get_property(index, index_is_id=index_is_id, loc=self.FIELD_MAP[fm])
|
return self.get_property(index, index_is_id=index_is_id, loc=self.FIELD_MAP[fm])
|
||||||
return func
|
return func
|
||||||
|
@ -15,6 +15,7 @@ from operator import itemgetter
|
|||||||
|
|
||||||
from calibre.db.tests.base import BaseTest
|
from calibre.db.tests.base import BaseTest
|
||||||
|
|
||||||
|
# Utils {{{
|
||||||
class ET(object):
|
class ET(object):
|
||||||
|
|
||||||
def __init__(self, func_name, args, kwargs={}, old=None, legacy=None):
|
def __init__(self, func_name, args, kwargs={}, old=None, legacy=None):
|
||||||
@ -58,6 +59,7 @@ def run_funcs(self, db, ndb, funcs):
|
|||||||
meth = meth[1:]
|
meth = meth[1:]
|
||||||
res1, res2 = fmt(getattr(db, meth)(*args)), fmt(getattr(ndb, meth)(*args))
|
res1, res2 = fmt(getattr(db, meth)(*args)), fmt(getattr(ndb, meth)(*args))
|
||||||
self.assertEqual(res1, res2, 'The method: %s() returned different results for argument %s' % (meth, args))
|
self.assertEqual(res1, res2, 'The method: %s() returned different results for argument %s' % (meth, args))
|
||||||
|
# }}}
|
||||||
|
|
||||||
class LegacyTest(BaseTest):
|
class LegacyTest(BaseTest):
|
||||||
|
|
||||||
@ -179,6 +181,7 @@ class LegacyTest(BaseTest):
|
|||||||
'sizeof_format':[(1, 'FMT1', True), (2, 'FMT1', True), (0, 'xxxxxx')],
|
'sizeof_format':[(1, 'FMT1', True), (2, 'FMT1', True), (0, 'xxxxxx')],
|
||||||
'@format_files':[(0,),(1,),(2,)],
|
'@format_files':[(0,),(1,),(2,)],
|
||||||
'formats':[(0,),(1,),(2,)],
|
'formats':[(0,),(1,),(2,)],
|
||||||
|
'max_size':[(0,),(1,),(2,)],
|
||||||
'format_hash':[(1, 'FMT1'),(1, 'FMT2'), (2, 'FMT1')],
|
'format_hash':[(1, 'FMT1'),(1, 'FMT2'), (2, 'FMT1')],
|
||||||
'author_sort_from_authors': [(['Author One', 'Author Two', 'Unknown'],)],
|
'author_sort_from_authors': [(['Author One', 'Author Two', 'Unknown'],)],
|
||||||
'has_book':[(Metadata('title one'),), (Metadata('xxxx1111'),)],
|
'has_book':[(Metadata('title one'),), (Metadata('xxxx1111'),)],
|
||||||
|
@ -959,7 +959,7 @@ ALTER TABLE books ADD COLUMN isbn TEXT DEFAULT "" COLLATE NOCASE;
|
|||||||
def max_size(self, index, index_is_id=False):
|
def max_size(self, index, index_is_id=False):
|
||||||
if index_is_id:
|
if index_is_id:
|
||||||
return self.conn.get('SELECT size FROM meta WHERE id=?', (index,), all=False)
|
return self.conn.get('SELECT size FROM meta WHERE id=?', (index,), all=False)
|
||||||
return self.data[index][6]
|
return self.data[index][4]
|
||||||
|
|
||||||
def cover(self, index, index_is_id=False):
|
def cover(self, index, index_is_id=False):
|
||||||
'''Cover as a data string or None'''
|
'''Cover as a data string or None'''
|
||||||
|
Loading…
x
Reference in New Issue
Block a user