diff --git a/src/calibre/gui2/catalog/catalog_epub_mobi.py b/src/calibre/gui2/catalog/catalog_epub_mobi.py
index ac51dd08bb..1ed11a55d7 100644
--- a/src/calibre/gui2/catalog/catalog_epub_mobi.py
+++ b/src/calibre/gui2/catalog/catalog_epub_mobi.py
@@ -75,7 +75,7 @@ class PluginWidget(QWidget,Ui_Form):
['radio_button' for i in RadioButtonControls])
# LineEditControls
- option_fields += zip(['exclude_genre'],['\[.+\]|\+'],['line_edit'])
+ option_fields += zip(['exclude_genre'],['\[.+\]|^\+$'],['line_edit'])
# TextEditControls
#option_fields += zip(['exclude_genre_results'],['excluded genres will appear here'],['text_edit'])
@@ -156,6 +156,32 @@ class PluginWidget(QWidget,Ui_Form):
Output:
self.exclude_genre_results (QLabel): updated to show tags to be excluded as genres
"""
+ def _truncated_results(excluded_tags, limit=180):
+ '''
+ Limit number of genres displayed to avoid dialog explosion
+ '''
+ start = []
+ end = []
+ lower = 0
+ upper = len(excluded_tags) -1
+ excluded_tags.sort()
+ while True:
+ if lower > upper:
+ break
+ elif lower == upper:
+ start.append(excluded_tags[lower])
+ break
+ start.append(excluded_tags[lower])
+ end.insert(0,excluded_tags[upper])
+ if len(', '.join(start)) + len(', '.join(end)) > limit:
+ break
+ lower += 1
+ upper -= 1
+ if excluded_tags == start + end:
+ return ', '.join(excluded_tags)
+ else:
+ return "%s ... %s" % (', '.join(start), ', '.join(end))
+
results = _('No genres will be excluded')
if not regex:
self.exclude_genre_results.clear()
@@ -176,7 +202,7 @@ class PluginWidget(QWidget,Ui_Form):
if set(excluded_tags) == set(self.all_tags):
results = _("All genres will be excluded")
else:
- results = ', '.join(sorted(excluded_tags))
+ results = _truncated_results(excluded_tags)
finally:
if self.DEBUG:
print(results)
diff --git a/src/calibre/gui2/catalog/catalog_epub_mobi.ui b/src/calibre/gui2/catalog/catalog_epub_mobi.ui
index 5e3a195190..b32e596f54 100644
--- a/src/calibre/gui2/catalog/catalog_epub_mobi.ui
+++ b/src/calibre/gui2/catalog/catalog_epub_mobi.ui
@@ -208,7 +208,7 @@ The default pattern \[.+\]|\+ excludes tags of the form [tag], e.g., [Test book]
-
+
@@ -223,7 +223,7 @@ The default pattern \[.+\]|\+ excludes tags of the form [tag], e.g., [Test book]
-
-
+
175
diff --git a/src/calibre/library/catalogs/epub_mobi.py b/src/calibre/library/catalogs/epub_mobi.py
index 9db05d5076..6225612cc8 100644
--- a/src/calibre/library/catalogs/epub_mobi.py
+++ b/src/calibre/library/catalogs/epub_mobi.py
@@ -51,7 +51,7 @@ class EPUB_MOBI(CatalogPlugin):
"Default: '%default'\n"
"Applies to: AZW3, ePub, MOBI output formats")),
Option('--exclude-genre',
- default='\[.+\]|\+',
+ default='\[.+\]|^\+$',
dest='exclude_genre',
action = None,
help=_("Regex describing tags to exclude as genres.\n"
@@ -313,18 +313,16 @@ class EPUB_MOBI(CatalogPlugin):
keys.sort()
build_log.append(" opts:")
for key in keys:
- if key in ['catalog_title','author_clip','connected_kindle','description_clip',
- 'exclude_book_marker','exclude_genre','exclude_tags',
- 'exclusion_rules', 'fmt',
+ if key in ['catalog_title','author_clip','connected_kindle','creator',
+ 'description_clip','exclude_book_marker','exclude_genre',
+ 'exclude_tags','exclusion_rules', 'fmt',
'header_note_source_field','merge_comments_rule',
'output_profile','prefix_rules','read_book_marker',
'search_text','sort_by','sort_descriptions_by_author','sync',
'thumb_width','use_existing_cover','wishlist_tag']:
build_log.append(" %s: %s" % (key, repr(opts_dict[key])))
-
if opts.verbose:
log('\n'.join(line for line in build_log))
-
self.opts = opts
# Launch the Catalog builder