mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-06-23 15:30:45 -04:00
Cleanup previous PR
This commit is contained in:
parent
9041c240f9
commit
ac76cbff0f
@ -64,10 +64,10 @@ class Field:
|
||||
is_many_many = False
|
||||
is_composite = False
|
||||
|
||||
def __init__(self, name, table, bools_are_tristate, get_template_functions, cache_weakref):
|
||||
def __init__(self, name, table, bools_are_tristate, get_template_functions, db_weakref):
|
||||
self.name, self.table = name, table
|
||||
dt = self.metadata['datatype']
|
||||
self.cache_weakref = cache_weakref
|
||||
self.db_weakref = db_weakref # this can be an instance of either Cache or LibraryDatabase
|
||||
self.has_text_data = dt in {'text', 'comments', 'series', 'enumeration'}
|
||||
self.table_type = self.table.table_type
|
||||
self._sort_key = (sort_key if dt in ('text', 'series', 'enumeration') else IDENTITY)
|
||||
@ -238,12 +238,11 @@ class CompositeField(OneToOneField):
|
||||
is_composite = True
|
||||
SIZE_SUFFIX_MAP = {suffix:i for i, suffix in enumerate(('', 'K', 'M', 'G', 'T', 'P', 'E'))}
|
||||
|
||||
def __init__(self, name, table, bools_are_tristate, get_template_functions, cache_weakref):
|
||||
OneToOneField.__init__(self, name, table, bools_are_tristate, get_template_functions, cache_weakref)
|
||||
def __init__(self, name, table, bools_are_tristate, get_template_functions, db_weakref):
|
||||
super().__init__(name, table, bools_are_tristate, get_template_functions, db_weakref)
|
||||
|
||||
self._render_cache = {}
|
||||
self._lock = Lock()
|
||||
self.cache_weakref = cache_weakref
|
||||
m = self.metadata
|
||||
self._composite_name = '#' + m['label']
|
||||
try:
|
||||
@ -299,7 +298,7 @@ class CompositeField(OneToOneField):
|
||||
|
||||
def __render_composite(self, book_id, mi, formatter, template_cache):
|
||||
' INTERNAL USE ONLY. DO NOT USE THIS OUTSIDE THIS CLASS! '
|
||||
db = self.cache_weakref()
|
||||
db = self.db_weakref()
|
||||
ans = formatter.safe_format(
|
||||
self.metadata['display']['composite_template'], mi, _('TEMPLATE ERROR'),
|
||||
mi, column_name=self._composite_name, template_cache=template_cache,
|
||||
@ -407,8 +406,9 @@ class CompositeField(OneToOneField):
|
||||
|
||||
class OnDeviceField(OneToOneField):
|
||||
|
||||
def __init__(self, name, table, bools_are_tristate, get_template_functions, cache_weakref):
|
||||
def __init__(self, name, table, bools_are_tristate, get_template_functions, db_weakref):
|
||||
self.name = name
|
||||
self.db_weakref = db_weakref
|
||||
self.book_on_device_func = None
|
||||
self.is_multiple = False
|
||||
self.cache = {}
|
||||
@ -802,7 +802,7 @@ class TagsField(ManyToManyField):
|
||||
return ans
|
||||
|
||||
|
||||
def create_field(name, table, bools_are_tristate, get_template_functions, cache_weakref):
|
||||
def create_field(name, table, bools_are_tristate, get_template_functions, db_weakref):
|
||||
cls = {
|
||||
ONE_ONE: OneToOneField,
|
||||
MANY_ONE: ManyToOneField,
|
||||
@ -822,4 +822,4 @@ def create_field(name, table, bools_are_tristate, get_template_functions, cache_
|
||||
cls = CompositeField
|
||||
elif table.metadata['datatype'] == 'series':
|
||||
cls = SeriesField
|
||||
return cls(name, table, bools_are_tristate, get_template_functions, cache_weakref)
|
||||
return cls(name, table, bools_are_tristate, get_template_functions, db_weakref)
|
||||
|
Loading…
x
Reference in New Issue
Block a user