diff --git a/src/calibre/ebooks/chm/input.py b/src/calibre/ebooks/chm/input.py index f55a76d67e..61160e8dac 100644 --- a/src/calibre/ebooks/chm/input.py +++ b/src/calibre/ebooks/chm/input.py @@ -51,6 +51,7 @@ class CHMInput(InputFormatPlugin): mainpath = os.path.join(tdir, mainname) metadata = get_metadata_from_reader(self._chm_reader) + self._chm_reader.CloseCHM() odi = options.debug_pipeline options.debug_pipeline = None diff --git a/src/calibre/ebooks/metadata/sources/base.py b/src/calibre/ebooks/metadata/sources/base.py index d9144fdf34..f322fcdb56 100644 --- a/src/calibre/ebooks/metadata/sources/base.py +++ b/src/calibre/ebooks/metadata/sources/base.py @@ -24,6 +24,7 @@ msprefs.defaults['ignore_fields'] = [] msprefs.defaults['max_tags'] = 20 msprefs.defaults['wait_after_first_identify_result'] = 30 # seconds msprefs.defaults['wait_after_first_cover_result'] = 60 # seconds +msprefs.defaults['swap_author_names'] = False # Google covers are often poor quality (scans/errors) but they have high # resolution, so they trump covers from better sources. So make sure they diff --git a/src/calibre/ebooks/metadata/sources/identify.py b/src/calibre/ebooks/metadata/sources/identify.py index 170ceb6c7a..87c1e9a644 100644 --- a/src/calibre/ebooks/metadata/sources/identify.py +++ b/src/calibre/ebooks/metadata/sources/identify.py @@ -365,6 +365,18 @@ def identify(log, abort, # {{{ for r in results: r.tags = r.tags[:max_tags] + if msprefs['swap_author_names']: + for r in results: + def swap_to_ln_fn(a): + if ',' in a: + return a + parts = a.split(None) + if len(parts) <= 1: + return a + surname = parts[-1] + return '%s, %s' % (surname, ' '.join(parts[:-1])) + r.authors = [swap_to_ln_fn(a) for a in r.authors] + return results # }}} diff --git a/src/calibre/ebooks/oeb/transforms/page_margin.py b/src/calibre/ebooks/oeb/transforms/page_margin.py index bc1925e343..d7c99d24c6 100644 --- a/src/calibre/ebooks/oeb/transforms/page_margin.py +++ b/src/calibre/ebooks/oeb/transforms/page_margin.py @@ -20,8 +20,9 @@ class RemoveAdobeMargins(object): self.oeb, self.opts, self.log = oeb, opts, log for item in self.oeb.manifest: - if item.media_type in ('application/vnd.adobe-page-template+xml', - 'application/vnd.adobe.page-template+xml'): + if (item.media_type in ('application/vnd.adobe-page-template+xml', + 'application/vnd.adobe.page-template+xml') and + hasattr(item.data, 'xpath')): self.log('Removing page margins specified in the' ' Adobe page template') for elem in item.data.xpath( diff --git a/src/calibre/gui2/metadata/basic_widgets.py b/src/calibre/gui2/metadata/basic_widgets.py index b2ee79c9c0..73913ba58f 100644 --- a/src/calibre/gui2/metadata/basic_widgets.py +++ b/src/calibre/gui2/metadata/basic_widgets.py @@ -846,7 +846,7 @@ class RatingEdit(QSpinBox): # {{{ class TagsEdit(MultiCompleteLineEdit): # {{{ LABEL = _('Ta&gs:') TOOLTIP = '

'+_('Tags categorize the book. This is particularly ' - 'useful while searching.

They can be any words' + 'useful while searching.

They can be any words ' 'or phrases, separated by commas.') def __init__(self, parent): diff --git a/src/calibre/gui2/preferences/metadata_sources.py b/src/calibre/gui2/preferences/metadata_sources.py index 17a70bcc33..9f2c441054 100644 --- a/src/calibre/gui2/preferences/metadata_sources.py +++ b/src/calibre/gui2/preferences/metadata_sources.py @@ -258,6 +258,7 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form): r('max_tags', msprefs) r('wait_after_first_identify_result', msprefs) r('wait_after_first_cover_result', msprefs) + r('swap_author_names', msprefs) self.configure_plugin_button.clicked.connect(self.configure_plugin) self.sources_model = SourcesModel(self) diff --git a/src/calibre/gui2/preferences/metadata_sources.ui b/src/calibre/gui2/preferences/metadata_sources.ui index b515f13ba1..37797eda5a 100644 --- a/src/calibre/gui2/preferences/metadata_sources.ui +++ b/src/calibre/gui2/preferences/metadata_sources.ui @@ -21,7 +21,7 @@ - + Metadata sources @@ -98,7 +98,14 @@ - + + + + Swap author names from FN LN to LN, FN + + + + Max. number of &tags to download: @@ -108,10 +115,10 @@ - + - + Max. &time to wait after first match is found: @@ -121,14 +128,14 @@ - + secs - + Max. time to wait after first &cover is found: @@ -138,7 +145,7 @@ - + secs diff --git a/src/calibre/gui2/search_box.py b/src/calibre/gui2/search_box.py index 98367fb808..359cb0b2f6 100644 --- a/src/calibre/gui2/search_box.py +++ b/src/calibre/gui2/search_box.py @@ -385,7 +385,7 @@ class SearchBoxMixin(object): # {{{ self.search_options_button.clicked.connect(self.search_options_button_clicked) self.set_highlight_only_button_icon() self.highlight_only_button.clicked.connect(self.highlight_only_clicked) - tt = _('Enable or disable search highlighting.') + '
' + tt = _('Enable or disable search highlighting.') + '

' tt += config.help('highlight_search_matches') self.highlight_only_button.setToolTip(tt)