コード例 #1
0
ファイル: legacy.py プロジェクト: T30rGRB7/calibre-python3
    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,
            load_user_formatter_functions=not is_second_db)
        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')
コード例 #2
0
ファイル: legacy.py プロジェクト: kobolabs/calibre
    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()