本文整理汇总了Python中calibre.db.view.View.refresh方法的典型用法代码示例。如果您正苦于以下问题:Python View.refresh方法的具体用法?Python View.refresh怎么用?Python View.refresh使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类calibre.db.view.View
的用法示例。
在下文中一共展示了View.refresh方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: LibraryDatabase
# 需要导入模块: from calibre.db.view import View [as 别名]
# 或者: from calibre.db.view.View import refresh [as 别名]
class LibraryDatabase(object):
''' Emulate the old LibraryDatabase2 interface '''
PATH_LIMIT = DB.PATH_LIMIT
WINDOWS_LIBRARY_PATH_LIMIT = DB.WINDOWS_LIBRARY_PATH_LIMIT
CATEGORY_SORTS = CATEGORY_SORTS
MATCH_TYPE = ('any', 'all')
CUSTOM_DATA_TYPES = frozenset(['rating', 'text', 'comments', 'datetime',
'int', 'float', 'bool', 'series', 'composite', 'enumeration'])
@classmethod
def exists_at(cls, path):
return path and os.path.exists(os.path.join(path, 'metadata.db'))
def __init__(self, library_path,
default_prefs=None, read_only=False, is_second_db=False,
progress_callback=lambda x, y:True, restore_all_prefs=False):
self.is_second_db = is_second_db # TODO: Use is_second_db
self.listeners = set()
backend = self.backend = DB(library_path, default_prefs=default_prefs,
read_only=read_only, restore_all_prefs=restore_all_prefs,
progress_callback=progress_callback)
cache = self.new_api = Cache(backend)
cache.init()
self.data = View(cache)
self.get_property = self.data.get_property
for prop in (
'author_sort', 'authors', 'comment', 'comments',
'publisher', 'rating', 'series', 'series_index', 'tags',
'title', 'timestamp', 'uuid', 'pubdate', 'ondevice',
'metadata_last_modified', 'languages',
):
fm = {'comment':'comments', 'metadata_last_modified':
'last_modified', 'title_sort':'sort'}.get(prop, prop)
setattr(self, prop, partial(self.get_property,
loc=self.FIELD_MAP[fm]))
for meth in ('get_next_series_num_for', 'has_book', 'author_sort_from_authors'):
setattr(self, meth, getattr(self.new_api, meth))
self.last_update_check = self.last_modified()
def close(self):
self.backend.close()
def break_cycles(self):
delattr(self.backend, 'field_metadata')
self.data.cache.backend = None
self.data.cache = None
for x in ('data', 'backend', 'new_api', 'listeners',):
delattr(self, x)
# Library wide properties {{{
@property
def field_metadata(self):
return self.backend.field_metadata
@property
def user_version(self):
return self.backend.user_version
@property
def library_id(self):
return self.backend.library_id
@property
def library_path(self):
return self.backend.library_path
@property
def dbpath(self):
return self.backend.dbpath
def last_modified(self):
return self.backend.last_modified()
def check_if_modified(self):
if self.last_modified() > self.last_update_check:
self.refresh()
self.last_update_check = utcnow()
@property
def custom_column_num_map(self):
return self.backend.custom_column_num_map
@property
def custom_column_label_map(self):
return self.backend.custom_column_label_map
@property
def FIELD_MAP(self):
return self.backend.FIELD_MAP
@property
def formatter_template_cache(self):
#.........这里部分代码省略.........
示例2: LibraryDatabase
# 需要导入模块: from calibre.db.view import View [as 别名]
# 或者: from calibre.db.view.View import refresh [as 别名]
class LibraryDatabase(object):
''' Emulate the old LibraryDatabase2 interface '''
PATH_LIMIT = DB.PATH_LIMIT
WINDOWS_LIBRARY_PATH_LIMIT = DB.WINDOWS_LIBRARY_PATH_LIMIT
CATEGORY_SORTS = CATEGORY_SORTS
MATCH_TYPE = ('any', 'all')
CUSTOM_DATA_TYPES = frozenset(['rating', 'text', 'comments', 'datetime',
'int', 'float', 'bool', 'series', 'composite', 'enumeration'])
@classmethod
def exists_at(cls, path):
return path and os.path.exists(os.path.join(path, 'metadata.db'))
def __init__(self, library_path,
default_prefs=None, read_only=False, is_second_db=False,
progress_callback=lambda x, y:True, restore_all_prefs=False):
self.is_second_db = is_second_db
self.listeners = set()
backend = self.backend = create_backend(library_path, default_prefs=default_prefs,
read_only=read_only, restore_all_prefs=restore_all_prefs,
progress_callback=progress_callback)
cache = self.new_api = Cache(backend)
cache.init()
self.data = View(cache)
self.id = self.data.index_to_id
self.row = self.data.id_to_index
for x in ('get_property', 'count', 'refresh_ids', 'set_marked_ids',
'multisort', 'search', 'search_getting_ids'):
setattr(self, x, getattr(self.data, x))
self.is_case_sensitive = getattr(backend, 'is_case_sensitive', False)
self.custom_field_name = backend.custom_field_name
self.last_update_check = self.last_modified()
if not self.is_second_db:
set_saved_searches(self, 'saved_searches')
def close(self):
self.new_api.close()
def break_cycles(self):
delattr(self.backend, 'field_metadata')
self.data.cache.backend = None
self.data.cache = None
for x in ('data', 'backend', 'new_api', 'listeners',):
delattr(self, x)
# Library wide properties {{{
@property
def prefs(self):
return self.new_api.backend.prefs
@property
def field_metadata(self):
return self.backend.field_metadata
@property
def user_version(self):
return self.backend.user_version
@property
def library_id(self):
return self.backend.library_id
@property
def library_path(self):
return self.backend.library_path
@property
def dbpath(self):
return self.backend.dbpath
def last_modified(self):
return self.new_api.last_modified()
def check_if_modified(self):
if self.last_modified() > self.last_update_check:
self.backend.reopen()
self.new_api.reload_from_db()
self.data.refresh(clear_caches=False) # caches are already cleared by reload_from_db()
self.last_update_check = utcnow()
@property
def custom_column_num_map(self):
return self.backend.custom_column_num_map
@property
def custom_column_label_map(self):
return self.backend.custom_column_label_map
@property
def FIELD_MAP(self):
return self.backend.FIELD_MAP
@property
#.........这里部分代码省略.........
示例3: LibraryDatabase
# 需要导入模块: from calibre.db.view import View [as 别名]
# 或者: from calibre.db.view.View import refresh [as 别名]
class LibraryDatabase(object):
""" Emulate the old LibraryDatabase2 interface """
PATH_LIMIT = DB.PATH_LIMIT
WINDOWS_LIBRARY_PATH_LIMIT = DB.WINDOWS_LIBRARY_PATH_LIMIT
CATEGORY_SORTS = CATEGORY_SORTS
MATCH_TYPE = ("any", "all")
CUSTOM_DATA_TYPES = frozenset(
["rating", "text", "comments", "datetime", "int", "float", "bool", "series", "composite", "enumeration"]
)
@classmethod
def exists_at(cls, path):
return path and os.path.exists(os.path.join(path, "metadata.db"))
def __init__(
self,
library_path,
default_prefs=None,
read_only=False,
is_second_db=False,
progress_callback=lambda x, y: True,
restore_all_prefs=False,
):
self.is_second_db = is_second_db # TODO: Use is_second_db
self.listeners = set([])
backend = self.backend = DB(
library_path,
default_prefs=default_prefs,
read_only=read_only,
restore_all_prefs=restore_all_prefs,
progress_callback=progress_callback,
)
cache = self.new_api = Cache(backend)
cache.init()
self.data = View(cache)
self.get_property = self.data.get_property
for prop in (
"author_sort",
"authors",
"comment",
"comments",
"publisher",
"rating",
"series",
"series_index",
"tags",
"title",
"timestamp",
"uuid",
"pubdate",
"ondevice",
"metadata_last_modified",
"languages",
):
fm = {"comment": "comments", "metadata_last_modified": "last_modified", "title_sort": "sort"}.get(
prop, prop
)
setattr(self, prop, partial(self.get_property, loc=self.FIELD_MAP[fm]))
self.last_update_check = self.last_modified()
def close(self):
self.backend.close()
def break_cycles(self):
self.data.cache.backend = None
self.data.cache = None
self.data = (
self.backend
) = self.new_api = self.field_metadata = self.prefs = self.listeners = self.refresh_ondevice = None
# Library wide properties {{{
@property
def field_metadata(self):
return self.backend.field_metadata
@property
def user_version(self):
return self.backend.user_version
@property
def library_id(self):
return self.backend.library_id
@property
def library_path(self):
return self.backend.library_path
@property
def dbpath(self):
return self.backend.dbpath
def last_modified(self):
return self.backend.last_modified()
#.........这里部分代码省略.........