mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 10:44:09 -04:00
...
This commit is contained in:
parent
a2e76a5993
commit
64503d07fe
@ -11,6 +11,13 @@ import weakref
|
|||||||
from functools import wraps
|
from functools import wraps
|
||||||
from collections import MutableMapping, MutableSequence
|
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):
|
def resolved(f):
|
||||||
@wraps(f)
|
@wraps(f)
|
||||||
def wrapper(self, *args, **kwargs):
|
def wrapper(self, *args, **kwargs):
|
||||||
@ -20,7 +27,7 @@ def resolved(f):
|
|||||||
return f(self, *args, **kwargs)
|
return f(self, *args, **kwargs)
|
||||||
return wrapper
|
return wrapper
|
||||||
|
|
||||||
class MutableBaseMixin(object): # {{{
|
class MutableBase(object):
|
||||||
|
|
||||||
@resolved
|
@resolved
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
@ -58,9 +65,8 @@ class MutableBaseMixin(object): # {{{
|
|||||||
def __delitem__(self, key):
|
def __delitem__(self, key):
|
||||||
del self._values[key]
|
del self._values[key]
|
||||||
|
|
||||||
# }}}
|
|
||||||
|
|
||||||
class FormatMetadata(MutableBaseMixin, MutableMapping): # {{{
|
class FormatMetadata(MutableBase, MutableMapping):
|
||||||
|
|
||||||
def __init__(self, db, id_, formats):
|
def __init__(self, db, id_, formats):
|
||||||
self._dbwref = weakref.ref(db)
|
self._dbwref = weakref.ref(db)
|
||||||
@ -76,7 +82,7 @@ class FormatMetadata(MutableBaseMixin, MutableMapping): # {{{
|
|||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
class FormatsList(MutableBaseMixin, MutableSequence):
|
class FormatsList(MutableBase, MutableSequence):
|
||||||
|
|
||||||
def __init__(self, formats, format_metadata):
|
def __init__(self, formats, format_metadata):
|
||||||
self._formats = formats
|
self._formats = formats
|
||||||
@ -91,4 +97,3 @@ class FormatsList(MutableBaseMixin, MutableSequence):
|
|||||||
|
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user