From b408cef83f992f6c8929f660adfa20c1f486b42e Mon Sep 17 00:00:00 2001 From: Jim Miller Date: Sun, 8 Jul 2012 21:51:38 -0500 Subject: [PATCH] Fixes for a couple obscure Generate Cover issues. --- calibre-plugin/config.py | 2 +- calibre-plugin/ffdl_plugin.py | 12 +++++++----- fanficdownloader/adapters/adapter_test1.py | 5 +++++ 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/calibre-plugin/config.py b/calibre-plugin/config.py index d4a3d6e..bc43597 100644 --- a/calibre-plugin/config.py +++ b/calibre-plugin/config.py @@ -552,7 +552,7 @@ class GenerateCoverTab(QWidget): self.gcnewonly.setChecked(prefs['gcnewonly']) self.l.addWidget(self.gcnewonly) - self.allow_gc_from_ini = QCheckBox('Allow generate_cover_settings from personal.ini to override.',self) + self.allow_gc_from_ini = QCheckBox('Allow generate_cover_settings from personal.ini to override',self) self.allow_gc_from_ini.setToolTip("The personal.ini parameter generate_cover_settings allows you to choose a GC setting based on metadata rather than site, but it's much more complex.
generate_cover_settings is ignored when this is off.") self.allow_gc_from_ini.setChecked(prefs['allow_gc_from_ini']) self.l.addWidget(self.allow_gc_from_ini) diff --git a/calibre-plugin/ffdl_plugin.py b/calibre-plugin/ffdl_plugin.py index 8a45e8b..5d65cc9 100644 --- a/calibre-plugin/ffdl_plugin.py +++ b/calibre-plugin/ffdl_plugin.py @@ -658,7 +658,6 @@ make_firstimage_cover:true custom_columns = self.gui.library_view.model().custom_columns if prefs['errorcol'] != '' and prefs['errorcol'] in custom_columns: label = custom_columns[prefs['errorcol']]['label'] - print("errorcol label:%s"%label) ## if error column and all bad. self.previous = self.gui.library_view.currentIndex() LoopProgressDialog(self.gui, @@ -784,7 +783,6 @@ make_firstimage_cover:true if prefs['errorcol'] != '' and prefs['errorcol'] in custom_columns: self.gui.status_bar.show_message(_('Adding/Updating %s BAD books.'%total_bad)) label = custom_columns[prefs['errorcol']]['label'] - print("errorcol label:%s"%label) ## if error column and all bad. LoopProgressDialog(self.gui, bad_list, @@ -895,8 +893,13 @@ make_firstimage_cover:true db.set_custom(book_id, val, label=label, commit=False) db.commit() - + if 'Generate Cover' in self.gui.iactions and (book['added'] or not prefs['gcnewonly']): + + # force a refresh if generating cover so complex composite + # custom columns are current and correct + db.refresh_ids([book_id]) + gc_plugin = self.gui.iactions['Generate Cover'] setting_name = None if prefs['allow_gc_from_ini']: @@ -911,7 +914,7 @@ make_firstimage_cover:true for line in adapter.getConfig('generate_cover_settings').splitlines(): if "=>" in line: (template,regexp,setting) = map( lambda x: x.strip(), line.split("=>") ) - value = Template(template).substitute(book['all_metadata']).encode('utf8') + value = Template(template).safe_substitute(book['all_metadata']).encode('utf8') print("%s(%s) => %s => %s"%(template,value,regexp,setting)) if re.search(regexp,value): setting_name = setting @@ -937,7 +940,6 @@ make_firstimage_cover:true ## if error column set. if prefs['errorcol'] != '' and prefs['errorcol'] in custom_columns: label = custom_columns[prefs['errorcol']]['label'] - print("_update_book label:%s"%label) db.set_custom(book['calibre_id'], '', label=label, commit=True) # book['comment'] def _get_clean_reading_lists(self,lists): diff --git a/fanficdownloader/adapters/adapter_test1.py b/fanficdownloader/adapters/adapter_test1.py index c85a673..ee4d876 100644 --- a/fanficdownloader/adapters/adapter_test1.py +++ b/fanficdownloader/adapters/adapter_test1.py @@ -114,10 +114,15 @@ Some more longer description. "I suck at summaries!" "Better than it sounds!" self.story.addToList('category','Crossover') self.story.addToList('category',u'Puella Magi Madoka Magica/魔法少女まどか★マギカ') self.story.addToList('category',u'Magical Girl Lyrical Nanoha') + self.story.addToList('genre','Fantasy') self.story.addToList('genre','SF') self.story.addToList('genre','Noir') + self.story.addToList('characters','Bob Smith') + self.story.addToList('characters','George Johnson') + self.story.addToList('characters','Fred Smythe') + self.chapterUrls = [(u'Prologue '+self.crazystring,self.url+"&chapter=1"), ('Chapter 1, Xenos on Cinnabar',self.url+"&chapter=2"), ('Chapter 2, Sinmay on Kintikin',self.url+"&chapter=3"),