def add_formats(self, book_id, paths, mi, replace=True, is_an_add=False): fmap = {p.rpartition(os.path.extsep)[-1].lower(): p for p in paths} fmt_map = {} for fmt, path in iteritems(fmap): # The onimport plugins have already been run by the read metadata # worker if self.ignore_opf and fmt.lower() == 'opf': continue try: if self.db.add_format(book_id, fmt, path, run_hooks=False, replace=replace): run_plugins_on_postimport(self.dbref(), book_id, fmt) fmt_map[fmt.lower()] = path except Exception: a = self.report.append a(''), a('-' * 70) a( _('Failed to add the file {0} to the book: {1}').format( path, mi.title)) a(_('With error:')), a(traceback.format_exc()) if is_an_add: run_plugins_on_postadd(self.dbref(), book_id, fmt_map)
def add_formats(self, book_id, paths, mi, replace=True, is_an_add=False): fmap = {p.rpartition(os.path.extsep)[-1].lower():p for p in paths} fmt_map = {} for fmt, path in fmap.iteritems(): # The onimport plugins have already been run by the read metadata # worker if self.ignore_opf and fmt.lower() == 'opf': continue try: if self.db.add_format(book_id, fmt, path, run_hooks=False, replace=replace): run_plugins_on_postimport(self.dbref(), book_id, fmt) fmt_map[fmt.lower()] = path except Exception: a = self.report.append a(''), a('-' * 70) a(_('Failed to add the file {0} to the book: {1}').format(path, mi.title)) a(_('With error:')), a(traceback.format_exc()) if is_an_add: run_plugins_on_postadd(self.dbref(), book_id, fmt_map)