예제 #1
0
 def __init__(
     self,
     dbcache,
     all_book_ids,
     gst,
     date_search,
     num_search,
     bool_search,
     keypair_search,
     limit_search_columns,
     limit_search_columns_to,
     locations,
     virtual_fields,
     lookup_saved_search,
     parse_cache,
 ):
     self.dbcache, self.all_book_ids = dbcache, all_book_ids
     self.all_search_locations = frozenset(locations)
     self.grouped_search_terms = gst
     self.date_search, self.num_search = date_search, num_search
     self.bool_search, self.keypair_search = bool_search, keypair_search
     self.limit_search_columns, self.limit_search_columns_to = (limit_search_columns, limit_search_columns_to)
     self.virtual_fields = virtual_fields or {}
     if "marked" not in self.virtual_fields:
         self.virtual_fields["marked"] = self
     SearchQueryParser.__init__(
         self, locations, optimize=True, lookup_saved_search=lookup_saved_search, parse_cache=parse_cache
     )
예제 #2
0
 def __init__(self):
     SearchQueryParser.__init__(self, locations=self.USABLE_LOCATIONS)
     self.srs = set([])
     # remove joiner words surrounded by space or at string boundaries
     self.joiner_pat = re.compile(r'(^|\s)(and|not|or|a|the|is|of)(\s|$)',
                                  re.IGNORECASE)
     self.punctuation_table = {ord(x): ' ' for x in string.punctuation}
예제 #3
0
    def __init__(self, keyboard, parent=None):
        QAbstractItemModel.__init__(self, parent)
        SearchQueryParser.__init__(self, ['all'])

        self.keyboard = keyboard
        groups = sorted(keyboard.groups, key=sort_key)
        shortcut_map = {
            k: v.copy()
            for k, v in iteritems(self.keyboard.shortcuts)
        }
        for un, s in iteritems(shortcut_map):
            s['keys'] = tuple(self.keyboard.keys_map.get(un, ()))
            s['unique_name'] = un
            s['group'] = [
                g for g, names in iteritems(self.keyboard.groups)
                if un in names
            ][0]

        group_map = {
            group: sorted(names,
                          key=lambda x: sort_key(shortcut_map[x]['name']))
            for group, names in iteritems(self.keyboard.groups)
        }

        self.data = [Node(group_map, shortcut_map, group) for group in groups]
예제 #4
0
 def __init__(self, FIELD_MAP, field_metadata, db_prefs=None):
     self.FIELD_MAP = FIELD_MAP
     self.db_prefs = db_prefs
     self.composites = {}
     self.udc = get_udc()
     for key in field_metadata:
         if field_metadata[key]['datatype'] == 'composite':
             self.composites[field_metadata[key]['rec_index']] = key
     self.series_col = field_metadata['series']['rec_index']
     self.series_sort_col = field_metadata['series_sort']['rec_index']
     self._data = []
     self._map = self._map_filtered = []
     self.first_sort = True
     self.search_restriction = self.base_restriction = ''
     self.base_restriction_name = self.search_restriction_name = ''
     self.search_restriction_book_count = 0
     self.marked_ids_dict = {}
     self.field_metadata = field_metadata
     self.all_search_locations = field_metadata.get_search_terms()
     SearchQueryParser.__init__(self, self.all_search_locations, optimize=True)
     self.build_date_relop_dict()
     self.build_numeric_relop_dict()
     # Do this here so the var get updated when a library changes
     global pref_use_primary_find_in_search
     pref_use_primary_find_in_search = prefs['use_primary_find_in_search']
예제 #5
0
 def __init__(self, show_only_user_plugins=False):
     QAbstractItemModel.__init__(self)
     SearchQueryParser.__init__(self, ['all'])
     self.show_only_user_plugins = show_only_user_plugins
     self.icon = QIcon(I('plugins.png'))
     p = QIcon(self.icon).pixmap(64, 64, QIcon.Disabled, QIcon.On)
     self.disabled_icon = QIcon(p)
     self._p = p
     self.populate()
예제 #6
0
 def __init__(self, show_only_user_plugins=False):
     QAbstractItemModel.__init__(self)
     SearchQueryParser.__init__(self, ['all'])
     self.show_only_user_plugins = show_only_user_plugins
     self.icon = QIcon(I('plugins.png'))
     p = QIcon(self.icon).pixmap(64, 64, QIcon.Disabled, QIcon.On)
     self.disabled_icon = QIcon(p)
     self._p = p
     self.populate()
예제 #7
0
파일: model.py 프로젝트: JapaChin/calibre
 def __init__(self, *args):
     QAbstractItemModel.__init__(self, *args)
     SearchQueryParser.__init__(self, locations=["all"])
     self.default_icon = QIcon(I("news.png"))
     self.custom_icon = QIcon(I("user_profile.png"))
     self.builtin_recipe_collection = get_builtin_recipe_collection()
     self.scheduler_config = SchedulerConfig()
     try:
         with zipfile.ZipFile(P("builtin_recipes.zip", allow_user_override=False), "r") as zf:
             self.favicons = dict([(x.filename, x) for x in zf.infolist() if x.filename.endswith(".png")])
     except:
         self.favicons = {}
     self.do_refresh()
예제 #8
0
파일: search.py 프로젝트: Hainish/calibre
 def __init__(self, dbcache, all_book_ids, gst, date_search, num_search,
              bool_search, keypair_search, limit_search_columns, limit_search_columns_to,
              locations, virtual_fields, lookup_saved_search, parse_cache):
     self.dbcache, self.all_book_ids = dbcache, all_book_ids
     self.all_search_locations = frozenset(locations)
     self.grouped_search_terms = gst
     self.date_search, self.num_search = date_search, num_search
     self.bool_search, self.keypair_search = bool_search, keypair_search
     self.limit_search_columns, self.limit_search_columns_to = (
         limit_search_columns, limit_search_columns_to)
     self.virtual_fields = virtual_fields or {}
     if 'marked' not in self.virtual_fields:
         self.virtual_fields['marked'] = self
     SearchQueryParser.__init__(self, locations, optimize=True, lookup_saved_search=lookup_saved_search, parse_cache=parse_cache)
예제 #9
0
 def __init__(self, *args):
     QAbstractItemModel.__init__(self, *args)
     SearchQueryParser.__init__(self, locations=['all'])
     self.default_icon = (QIcon(I('news.png')))
     self.custom_icon = (QIcon(I('user_profile.png')))
     self.builtin_recipe_collection = get_builtin_recipe_collection()
     self.scheduler_config = SchedulerConfig()
     try:
         with zipfile.ZipFile(P('builtin_recipes.zip',
                 allow_user_override=False), 'r') as zf:
             self.favicons = dict([(x.filename, x) for x in zf.infolist() if
                 x.filename.endswith('.png')])
     except:
         self.favicons = {}
     self.do_refresh()
예제 #10
0
파일: keyboard.py 프로젝트: hashken/calibre
    def __init__(self, keyboard, parent=None):
        QAbstractItemModel.__init__(self, parent)
        SearchQueryParser.__init__(self, ["all"])

        self.keyboard = keyboard
        groups = sorted(keyboard.groups, key=sort_key)
        shortcut_map = {k: v.copy() for k, v in self.keyboard.shortcuts.iteritems()}
        for un, s in shortcut_map.iteritems():
            s["keys"] = tuple(self.keyboard.keys_map.get(un, ()))
            s["unique_name"] = un
            s["group"] = [g for g, names in self.keyboard.groups.iteritems() if un in names][0]

        group_map = {
            group: sorted(names, key=lambda x: sort_key(shortcut_map[x]["name"]))
            for group, names in self.keyboard.groups.iteritems()
        }

        self.data = [Node(group_map, shortcut_map, group) for group in groups]
예제 #11
0
파일: jobs.py 프로젝트: Eksmo/calibre
    def __init__(self):
        QAbstractTableModel.__init__(self)
        SearchQueryParser.__init__(self, ["all"])

        self.wait_icon = QVariant(QIcon(I("jobs.png")))
        self.running_icon = QVariant(QIcon(I("exec.png")))
        self.error_icon = QVariant(QIcon(I("dialog_error.png")))
        self.done_icon = QVariant(QIcon(I("ok.png")))

        self.jobs = []
        self.add_job = Dispatcher(self._add_job)
        self.server = Server(limit=int(config["worker_limit"] / 2.0), enforce_cpu_limit=config["enforce_cpu_limit"])
        self.threaded_server = ThreadedJobServer()
        self.changed_queue = Queue()

        self.timer = QTimer(self)
        self.timer.timeout.connect(self.update, type=Qt.QueuedConnection)
        self.timer.start(1000)
예제 #12
0
파일: jobs.py 프로젝트: oatall/calibre
    def __init__(self):
        QAbstractTableModel.__init__(self)
        SearchQueryParser.__init__(self, ['all'])

        self.wait_icon = (QIcon(I('jobs.png')))
        self.running_icon = (QIcon(I('exec.png')))
        self.error_icon = (QIcon(I('dialog_error.png')))
        self.done_icon = (QIcon(I('ok.png')))

        self.jobs = []
        self.add_job = Dispatcher(self._add_job)
        self.server = Server(limit=int(config['worker_limit'] / 2.0),
                             enforce_cpu_limit=config['enforce_cpu_limit'])
        self.threaded_server = ThreadedJobServer()
        self.changed_queue = Queue()

        self.timer = QTimer(self)
        self.timer.timeout.connect(self.update, type=Qt.QueuedConnection)
        self.timer.start(1000)
예제 #13
0
 def parse(self, *args, **kwargs):
     self.virtual_field_used = False
     return SearchQueryParser.parse(self, *args, **kwargs)
예제 #14
0
    def __init__(self, parent=None):
        QAbstractListModel.__init__(self, parent)
        SearchQueryParser.__init__(self, ['all'])
        raw_defaults, raw_custom = read_raw_tweaks()

        self.parse_tweaks(raw_defaults, raw_custom)
예제 #15
0
파일: search.py 프로젝트: Pipeliner/calibre
 def parse(self, *args, **kwargs):
     self.virtual_field_used = False
     return SearchQueryParser.parse(self, *args, **kwargs)
예제 #16
0
 def __init__(self, all_plugins=[]):
     SearchQueryParser.__init__(self, locations=self.USABLE_LOCATIONS)
     self.srs = set(all_plugins)
예제 #17
0
파일: models.py 프로젝트: Eksmo/calibre
 def __init__(self, all_plugins=[]):
     SearchQueryParser.__init__(self, locations=self.USABLE_LOCATIONS)
     self.srs = set(all_plugins)
예제 #18
0
파일: tweaks.py 프로젝트: JimmXinu/calibre
 def __init__(self, parent=None):
     QAbstractListModel.__init__(self, parent)
     SearchQueryParser.__init__(self, ['all'])
     self.parse_tweaks()
예제 #19
0
 def __init__(self, parent=None):
     QAbstractListModel.__init__(self, parent)
     SearchQueryParser.__init__(self, ['all'])
     self.parse_tweaks()
예제 #20
0
파일: models.py 프로젝트: Eksmo/calibre
 def __init__(self):
     SearchQueryParser.__init__(self, locations=self.USABLE_LOCATIONS)
     self.srs = set([])
예제 #21
0
파일: tweaks.py 프로젝트: rakyi/calibre
    def __init__(self, parent=None):
        QAbstractListModel.__init__(self, parent)
        SearchQueryParser.__init__(self, ['all'])
        raw_defaults, raw_custom = read_raw_tweaks()

        self.parse_tweaks(raw_defaults, raw_custom)
예제 #22
0
 def __init__(self):
     SearchQueryParser.__init__(self, locations=self.USABLE_LOCATIONS)
     self.srs = set([])
예제 #23
0
파일: models.py 프로젝트: AEliu/calibre
 def __init__(self):
     SearchQueryParser.__init__(self, locations=self.USABLE_LOCATIONS)
     self.srs = set([])
     # remove joiner words surrounded by space or at string boundaries
     self.joiner_pat = re.compile(r'(^|\s)(and|not|or|a|the|is|of)(\s|$)', re.IGNORECASE)
     self.punctuation_table = {ord(x):' ' for x in string.punctuation}