예제 #1
0
    def _do_count_pages(self, book_ids, statistics_cols_map, use_goodreads):
        # Create a temporary directory to copy all the ePubs to while scanning
        tdir = PersistentTemporaryDirectory('_count_pages', prefix='')

        # Queue all the books and kick off the job
        c = cfg.plugin_prefs[cfg.STORE_NAME]
        db = self.gui.current_db
        library_config = cfg.get_library_config(db)
        pages_algorithm = library_config.get(cfg.KEY_PAGES_ALGORITHM,
                                cfg.DEFAULT_LIBRARY_VALUES[cfg.KEY_PAGES_ALGORITHM])
        overwrite_existing = c.get(cfg.KEY_OVERWRITE_EXISTING,
                                   cfg.DEFAULT_STORE_VALUES[cfg.KEY_OVERWRITE_EXISTING])
        QueueProgressDialog(self.gui, book_ids, tdir, statistics_cols_map,
                            pages_algorithm, use_goodreads,
                            overwrite_existing, self._queue_job, db)
예제 #2
0
    def _get_column_validity(self, statistics_to_run):
        '''
        Given a list of algorithms requested to be run, lookup what custom
        columns are configured and return a dict for each possible statistic
        and its associated custom column (blank if not to be run).
        '''
        db = self.gui.current_db
        all_cols = db.field_metadata.custom_field_metadata()

        library_config = cfg.get_library_config(db)
        statistics_cols_map = {}
        any_valid = False
        for statistic, statistic_col_key in cfg.ALL_STATISTICS.iteritems():
            col = library_config.get(statistic_col_key, '')
            is_requested = statistic in statistics_to_run
            is_valid = is_requested and len(col) > 0 and col in all_cols
            if not is_valid or not col:
                statistics_cols_map[statistic] = ''
            else:
                any_valid = True
                statistics_cols_map[statistic] = col
        return any_valid, statistics_cols_map