From 5193be1c5aa2de4b6281a3e3c92118c2a1b6888d Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 4 Dec 2009 16:57:11 -0700 Subject: [PATCH 1/3] Fix PML input plugin --- src/calibre/customize/builtins.py | 33 +++++++++++++------------------ 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/src/calibre/customize/builtins.py b/src/calibre/customize/builtins.py index a8ad352b9b..adb0f52539 100644 --- a/src/calibre/customize/builtins.py +++ b/src/calibre/customize/builtins.py @@ -54,10 +54,10 @@ class PML2PMLZ(FileTypePlugin): name = 'PML to PMLZ' author = 'John Schember' description = textwrap.dedent(_('''\ - Create a PMLZ archive containing the PML file \ - and all images in the directory pmlname_img or images \ - file containing all linked files. This plugin is run \ - every time you add an PML file to the library.\ + Create a PMLZ archive containing the PML file + and all images in the directory pmlname_img or images. + This plugin is run every time you add + a PML file to the library. ''')) version = numeric_version file_types = set(['pml']) @@ -66,25 +66,20 @@ class PML2PMLZ(FileTypePlugin): def run(self, pmlfile): import zipfile - from calibre.ptempfile import TemporaryDirectory - with TemporaryDirectory('_plugin_pml2pmlz') as tdir: - name = os.path.join(tdir, '_plugin_pml2pmlz.pmlz') - pmlz = zipfile.ZipFile(name, 'w') - pmlz.write(pmlfile) + of = self.temporary_file('_plugin_pml2pmlz.pmlz') + pmlz = zipfile.ZipFile(of.name, 'w') + pmlz.write(pmlfile, os.path.basename(pmlfile)) - pml_img = os.path.basename(pmlfile)[0] + '_img' - img_dir = pml_img if os.path.exists(pml_img) else 'images' if \ + pml_img = os.path.basename(pmlfile)[0] + '_img' + img_dir = pml_img if os.path.exists(pml_img) else 'images' if \ os.path.exists('images') else '' - if img_dir: - for image in glob.glob(os.path.join(img_dir, '*.png')): - pmlz.write(image) - pmlz.close() + if img_dir: + for image in glob.glob(os.path.join(img_dir, '*.png')): + pmlz.write(image, os.path.join('images', (os.path.basename(image)))) + pmlz.close() - return name - - def customization_help(self, gui=False): - return _('Character encoding for the input PML files. Should ways be: cp1252.') + return of.name class ComicMetadataReader(MetadataReaderPlugin): From 9a6754b01d22cde73acd4a54fc62faf6e8796b30 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 4 Dec 2009 17:18:48 -0700 Subject: [PATCH 2/3] Fix #4133 (Add all sections to the Arizona Daily Star News Feed) --- resources/recipes/azstarnet.recipe | 34 +++++++++++++++------------- src/calibre/customize/builtins.py | 10 ++++---- src/calibre/ebooks/metadata/fetch.py | 2 ++ 3 files changed, 24 insertions(+), 22 deletions(-) diff --git a/resources/recipes/azstarnet.recipe b/resources/recipes/azstarnet.recipe index 9b18081598..83bebba614 100644 --- a/resources/recipes/azstarnet.recipe +++ b/resources/recipes/azstarnet.recipe @@ -1,4 +1,3 @@ -#!/usr/bin/env python __license__ = 'GPL v3' __copyright__ = '2009, Darko Miletic ' @@ -12,26 +11,24 @@ class Azstarnet(BasicNewsRecipe): title = 'Arizona Daily Star' __author__ = 'Darko Miletic' description = 'news from Arizona' - language = 'en' - + language = 'en' publisher = 'azstarnet.com' category = 'news, politics, Arizona, USA' delay = 1 - oldest_article = 1 + oldest_article = 3 max_articles_per_feed = 100 no_stylesheets = True use_embedded_content = False encoding = 'utf-8' needs_subscription = True - remove_javascript = True - html2lrf_options = [ - '--comment', description - , '--category', category - , '--publisher', publisher - ] + conversion_options = { + 'comment' : description + , 'tags' : category + , 'publisher' : publisher + , 'language' : language + } - html2epub_options = 'publisher="' + publisher + '"\ncomments="' + description + '"\ntags="' + category + '"' def get_browser(self): br = BasicNewsRecipe.get_browser() @@ -52,14 +49,19 @@ class Azstarnet(BasicNewsRecipe): ] - feeds = [(u'Tucson Region', u'http://rss.azstarnet.com/index.php?site=metro')] + feeds = [ + (u'Tucson Region', u'http://rss.azstarnet.com/index.php?site=metro') + ,(u'Sports' , u'http://rss.azstarnet.com/index.php?site=sports') + ,(u'Business' , u'http://rss.azstarnet.com/index.php?site=biz-topheadlines') + ,(u'Nation-World' , u'http://rss.azstarnet.com/index.php?site=news') + ,(u'Opinion' , u'http://rss.azstarnet.com/index.php?site=opinion') + ,(u'Lifestyle' , u'http://rss.azstarnet.com/index.php?site=accent') + ,(u'Food' , u'http://rss.azstarnet.com/index.php?site=food') + ] def preprocess_html(self, soup): - soup.html['dir' ] = 'ltr' - soup.html['lang'] = 'en-US' - mtag = '\n\n\n' - soup.head.insert(0,mtag) for item in soup.findAll(style=True): del item['style'] return soup + diff --git a/src/calibre/customize/builtins.py b/src/calibre/customize/builtins.py index adb0f52539..c317decd76 100644 --- a/src/calibre/customize/builtins.py +++ b/src/calibre/customize/builtins.py @@ -53,12 +53,10 @@ every time you add an HTML file to the library.\ class PML2PMLZ(FileTypePlugin): name = 'PML to PMLZ' author = 'John Schember' - description = textwrap.dedent(_('''\ - Create a PMLZ archive containing the PML file - and all images in the directory pmlname_img or images. - This plugin is run every time you add - a PML file to the library. - ''')) + description = _('Create a PMLZ archive containing the PML file ' + 'and all images in the directory pmlname_img or images. ' + 'This plugin is run every time you add ' + 'a PML file to the library.') version = numeric_version file_types = set(['pml']) supported_platforms = ['windows', 'osx', 'linux'] diff --git a/src/calibre/ebooks/metadata/fetch.py b/src/calibre/ebooks/metadata/fetch.py index f308ddb043..aca975e4b9 100644 --- a/src/calibre/ebooks/metadata/fetch.py +++ b/src/calibre/ebooks/metadata/fetch.py @@ -128,6 +128,8 @@ class MetadataSource(Plugin): from calibre.customize.ui import customize_plugin customize_plugin(self, sc) + def customization_help(self): + return 'This plugin can only be customized using the GUI' class GoogleBooks(MetadataSource): From 90fb3e210856aa38f01e2d855f44332fbae64f49 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 4 Dec 2009 17:25:14 -0700 Subject: [PATCH 3/3] Linux source install: Write path to bin dir into launcher scripts to make IPC more robust --- setup/install.py | 2 ++ src/calibre/utils/ipc/launch.py | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/setup/install.py b/setup/install.py index 0ac23582c7..4aab6a4761 100644 --- a/setup/install.py +++ b/setup/install.py @@ -26,6 +26,7 @@ sys.path.insert(0, path) sys.resources_location = os.environ.get('CALIBRE_RESOURCES_PATH', {resources!r}) sys.extensions_location = os.environ.get('CALIBRE_EXTENSIONS_PATH', {extensions!r}) +sys.executables_location = os.environ.get('CALIBRE_EXECUTABLES_PATH', {executables!r}) ''' @@ -184,6 +185,7 @@ class Develop(Command): script = template.format( module=mod, func=func, path=self.libdir, resources=self.sharedir, + executables=self.staging_bindir, extensions=self.j(self.libdir, 'calibre', 'plugins')) path = self.j(self.staging_bindir, name) if not os.path.exists(self.staging_bindir): diff --git a/src/calibre/utils/ipc/launch.py b/src/calibre/utils/ipc/launch.py index 0432143ae2..dbabfe86b2 100644 --- a/src/calibre/utils/ipc/launch.py +++ b/src/calibre/utils/ipc/launch.py @@ -55,7 +55,8 @@ class Worker(object): return os.path.join(contents, 'MacOS', self.osx_interpreter) return os.path.join(getattr(sys, 'frozen_path'), 'calibre-parallel') \ - if isfrozen else 'calibre-parallel' + if isfrozen else \ + os.path.join(sys.executables_location, 'calibre-parallel') @property def gui_executable(self):