From e101896e5720e58685633c3a5828cf88263ea323 Mon Sep 17 00:00:00 2001 From: John Schember Date: Thu, 5 May 2011 06:49:36 -0400 Subject: [PATCH 1/5] HTMLZ: metadata replace metadata after merging. APNX don't use tag starting with d as paragraph tag as it breaks more than it fixes. --- src/calibre/devices/kindle/apnx.py | 2 +- src/calibre/ebooks/metadata/extz.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/calibre/devices/kindle/apnx.py b/src/calibre/devices/kindle/apnx.py index ee519750e0..178c1091f3 100644 --- a/src/calibre/devices/kindle/apnx.py +++ b/src/calibre/devices/kindle/apnx.py @@ -164,7 +164,7 @@ class APNXBuilder(object): if c == '/': closing = True continue - elif c in ('d', 'p'): + elif c == 'p': if closing: in_p = False else: diff --git a/src/calibre/ebooks/metadata/extz.py b/src/calibre/ebooks/metadata/extz.py index 1bda263015..021450fca5 100644 --- a/src/calibre/ebooks/metadata/extz.py +++ b/src/calibre/ebooks/metadata/extz.py @@ -70,7 +70,7 @@ def set_metadata(stream, mi): # Update the metadata. old_mi = opf.to_book_metadata() old_mi.smart_update(mi) - opf.smart_update(metadata_to_opf(old_mi)) + opf.smart_update(metadata_to_opf(old_mi), replace_metadata=True) newopf = StringIO(opf.render()) safe_replace(stream, opf_path, newopf, extra_replacements=replacements, add_missing=True) From 6dc8803ac569d739f1b53a76faaf6a510c80eb3f Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 5 May 2011 09:21:31 -0600 Subject: [PATCH 2/5] Add uri->url identifiers mapping --- src/calibre/ebooks/metadata/sources/identify.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/calibre/ebooks/metadata/sources/identify.py b/src/calibre/ebooks/metadata/sources/identify.py index 3d4807ac02..1bd071d6f9 100644 --- a/src/calibre/ebooks/metadata/sources/identify.py +++ b/src/calibre/ebooks/metadata/sources/identify.py @@ -13,6 +13,7 @@ from Queue import Queue, Empty from threading import Thread from io import BytesIO from operator import attrgetter +from urlparse import urlparse from calibre.customize.ui import metadata_plugins, all_metadata_plugins from calibre.ebooks.metadata.sources.base import create_log, msprefs @@ -458,6 +459,14 @@ def urls_from_identifiers(identifiers): # {{{ if oclc: ans.append(('OCLC', 'oclc', oclc, 'http://www.worldcat.org/oclc/'+oclc)) + url = identifiers.get('uri', None) + if url is None: + url = identifiers.get('url', None) + if url and url.startswith('http'): + url = url[:8].replace('|', ':') + url[8:].replace('|', ',') + parts = urlparse(url) + name = parts.netloc + ans.append((name, 'url', url, url)) return ans # }}} From d371225d5d36dcc294fdda40a1b551a986f548a1 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 5 May 2011 14:20:51 -0600 Subject: [PATCH 3/5] ... --- src/calibre/gui2/actions/choose_library.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/calibre/gui2/actions/choose_library.py b/src/calibre/gui2/actions/choose_library.py index f6b19fc4aa..9fd156b802 100644 --- a/src/calibre/gui2/actions/choose_library.py +++ b/src/calibre/gui2/actions/choose_library.py @@ -246,7 +246,8 @@ class ChooseLibraryAction(InterfaceAction): def delete_requested(self, name, location): loc = location.replace('/', os.sep) if not question_dialog(self.gui, _('Are you sure?'), '

'+ - _('All files from

%s

will be ' + _('All files (not just ebooks) ' + 'from

%s

will be ' 'permanently deleted. Are you sure?') % loc, show_copy_button=False): return From 1647e17684a07b29501b4a2ef4bfdd59e989f390 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 5 May 2011 14:34:41 -0600 Subject: [PATCH 4/5] Fix two zero byte files being left behind after calibre quits on windows --- setup/installer/windows/main.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/setup/installer/windows/main.c b/setup/installer/windows/main.c index d76850504e..780be94330 100644 --- a/setup/installer/windows/main.c +++ b/setup/installer/windows/main.c @@ -23,6 +23,9 @@ wWinMain(HINSTANCE Inst, HINSTANCE PrevInst, ret = execute_python_entrypoint(BASENAME, MODULE, FUNCTION, stdout_redirect, stderr_redirect); + if (stdout != NULL) fclose(stdout); + if (stderr != NULL) fclose(stderr); + DeleteFile(stdout_redirect); DeleteFile(stderr_redirect); From e277a9218930b9aef5a60a963a45fa070b7c1461 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 5 May 2011 14:44:54 -0600 Subject: [PATCH 5/5] Fix temp file leak when restarting calibre from within itself --- src/calibre/gui2/main.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/calibre/gui2/main.py b/src/calibre/gui2/main.py index eadfa55549..645ce3b228 100644 --- a/src/calibre/gui2/main.py +++ b/src/calibre/gui2/main.py @@ -299,13 +299,13 @@ def run_gui(opts, args, actions, listener, app, gui_debug=None): if getattr(runner.main, 'debug_on_restart', False): run_in_debug_mode() else: + import subprocess print 'Restarting with:', e, sys.argv if hasattr(sys, 'frameworks_dir'): app = os.path.dirname(os.path.dirname(sys.frameworks_dir)) - import subprocess subprocess.Popen('sleep 3s; open '+app, shell=True) else: - os.execvp(e, sys.argv) + subprocess.Popen([e] + sys.argv[1:]) else: if iswindows: try: