mirror of
git://github.com/kovidgoyal/calibre.git
synced 2025-12-27 09:16:23 +01:00
...
This commit is contained in:
parent
a2e76a5993
commit
64503d07fe
1 changed files with 10 additions and 5 deletions
|
|
@ -11,6 +11,13 @@
|
|||
from functools import wraps
|
||||
from collections import MutableMapping, MutableSequence
|
||||
|
||||
'''
|
||||
Avoid doing stats on all files in a book when getting metadata for that book.
|
||||
Speeds up calibre startup with large libraries/libraries on a network share,
|
||||
with a composite custom column.
|
||||
'''
|
||||
|
||||
# Lazy format metadata retrieval {{{
|
||||
def resolved(f):
|
||||
@wraps(f)
|
||||
def wrapper(self, *args, **kwargs):
|
||||
|
|
@ -20,7 +27,7 @@ def wrapper(self, *args, **kwargs):
|
|||
return f(self, *args, **kwargs)
|
||||
return wrapper
|
||||
|
||||
class MutableBaseMixin(object): # {{{
|
||||
class MutableBase(object):
|
||||
|
||||
@resolved
|
||||
def __str__(self):
|
||||
|
|
@ -58,9 +65,8 @@ def __setitem__(self, key, val):
|
|||
def __delitem__(self, key):
|
||||
del self._values[key]
|
||||
|
||||
# }}}
|
||||
|
||||
class FormatMetadata(MutableBaseMixin, MutableMapping): # {{{
|
||||
class FormatMetadata(MutableBase, MutableMapping):
|
||||
|
||||
def __init__(self, db, id_, formats):
|
||||
self._dbwref = weakref.ref(db)
|
||||
|
|
@ -76,7 +82,7 @@ def _resolve(self):
|
|||
except:
|
||||
pass
|
||||
|
||||
class FormatsList(MutableBaseMixin, MutableSequence):
|
||||
class FormatsList(MutableBase, MutableSequence):
|
||||
|
||||
def __init__(self, formats, format_metadata):
|
||||
self._formats = formats
|
||||
|
|
@ -91,4 +97,3 @@ def insert(self, idx, val):
|
|||
|
||||
# }}}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue