diff --git a/.bzrignore b/.bzrignore index bd265eb830..c7e6351e21 100644 --- a/.bzrignore +++ b/.bzrignore @@ -9,6 +9,8 @@ dist docs resources/localization resources/images.qrc +resources/recipes.pickle +resources/scripts.pickle installer/windows/calibre/build.log src/calibre/translations/.errors src/cssutils/.svn/ diff --git a/setup/commands.py b/setup/commands.py index 57ef2c63bf..fbbc15a27c 100644 --- a/setup/commands.py +++ b/setup/commands.py @@ -11,6 +11,7 @@ __all__ = [ 'build', 'gui', 'develop', + 'resources', 'check', ] @@ -33,6 +34,9 @@ gui = GUI() from setup.check import Check check = Check() +from setup.resources import Resources +resources = Resources() + commands = {} for x in __all__: commands[x] = locals()[x] diff --git a/setup/resources.py b/setup/resources.py new file mode 100644 index 0000000000..3e491fd9f0 --- /dev/null +++ b/setup/resources.py @@ -0,0 +1,57 @@ +#!/usr/bin/env python +# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai +from __future__ import with_statement + +__license__ = 'GPL v3' +__copyright__ = '2009, Kovid Goyal ' +__docformat__ = 'restructuredtext en' + +import os, cPickle + +from setup import Command, basenames + +class Resources(Command): + + def get_recipes(self): + sdir = os.path.join('src', 'calibre', 'web', 'feeds', 'recipes') + resources= {} + files = [] + for f in os.listdir(sdir): + if f.endswith('.py') and f != '__init__.py': + files.append(os.path.join(sdir, f)) + resources[f.replace('.py', '')] = open(files[-1], 'rb').read() + return resources, files + + + def run(self, opts): + scripts = {} + for x in ('console', 'gui'): + for name in basenames[x]: + if name in ('calibre-complete', 'calibre_postinstall'): + continue + scripts[name] = x + + dest = self.j(self.RESOURCES, 'scripts.pickle') + if self.newer(dest, self.j(self.SRC, 'calibre', 'linux.py')): + self.info('\tCreating scripts.pickle') + f = open(dest, 'wb') + cPickle.dump(scripts, f, -1) + + recipes, files = self.get_recipes() + + dest = self.j(self.RESOURCES, 'recipes.pickle') + if self.newer(dest, files): + self.info('\tCreating recipes.pickle') + f = open(dest, 'wb') + cPickle.dump(recipes, f, -1) + + + def clean(self): + for x in ('scripts', 'recipes'): + x = self.j(self.RESOURCES, x+'.pickle') + if os.path.exists(x): + os.remove(x) + + + + diff --git a/src/calibre/ebooks/metadata/fb2.py b/src/calibre/ebooks/metadata/fb2.py index 03e3117d3e..576fbaa6fc 100644 --- a/src/calibre/ebooks/metadata/fb2.py +++ b/src/calibre/ebooks/metadata/fb2.py @@ -46,6 +46,7 @@ def get_metadata(stream): _('Unknown'))))[0] for x in XPath('//fb2:book-title')(root): title = tostring(x) + break comments = '' for x in XPath('//fb2:annotation')(root): comments += tostring(x) diff --git a/src/calibre/gui2/dialogs/user_profiles.py b/src/calibre/gui2/dialogs/user_profiles.py index 6a4a3275a8..4584e10793 100644 --- a/src/calibre/gui2/dialogs/user_profiles.py +++ b/src/calibre/gui2/dialogs/user_profiles.py @@ -1,6 +1,6 @@ __license__ = 'GPL v3' __copyright__ = '2008, Kovid Goyal ' -import time, os +import time, os, cPickle from PyQt4.QtCore import SIGNAL, QUrl from PyQt4.QtGui import QDesktopServices @@ -185,9 +185,10 @@ class %(classname)s(%(base_class)s): def add_builtin_recipe(self): from calibre.web.feeds.recipes import recipes, recipe_modules, english_sort - from calibre.resources import recipes as rdat from PyQt4.Qt import QInputDialog + rdat = cPickle.load(open(P('recipes.pickle'), 'rb')) + class Recipe(object): def __init__(self, title, id, recipes): self.title = unicode(title) diff --git a/src/calibre/utils/osx_symlinks.py b/src/calibre/utils/osx_symlinks.py index 6aa7fb5d0a..2cfdd72fa3 100644 --- a/src/calibre/utils/osx_symlinks.py +++ b/src/calibre/utils/osx_symlinks.py @@ -6,7 +6,7 @@ __license__ = 'GPL v3' __copyright__ = '2009, Kovid Goyal ' __docformat__ = 'restructuredtext en' -import sys, os +import sys, os, cPickle AUTHTOOL="""#!/usr/bin/python import os @@ -29,8 +29,11 @@ DEST_PATH = '/usr/bin' def create_symlinks(): return create_symlinks_new() if getattr(sys, 'new_app_bundle', False) else create_symlinks_old() +def get_scripts(): + return cPickle.load(open(P('scripts.pickle'), 'rb')) + def create_symlinks_new(): - from calibre.resources import scripts + scripts = get_scripts() links = [os.path.join(DEST_PATH, i) for i in scripts] scripts = [os.path.join( @@ -40,7 +43,7 @@ def create_symlinks_new(): def create_symlinks_old(): - from calibre.resources import scripts + scripts = get_scripts() resources_path = os.environ['RESOURCEPATH'] links = [os.path.join(DEST_PATH, i) for i in scripts] diff --git a/src/calibre/web/feeds/recipes/recipe_tomshardware_de.py b/src/calibre/web/feeds/recipes/recipe_tomshardware_de.py index 90b53101cb..aad3d60b17 100644 --- a/src/calibre/web/feeds/recipes/recipe_tomshardware_de.py +++ b/src/calibre/web/feeds/recipes/recipe_tomshardware_de.py @@ -17,9 +17,8 @@ class cdnet(BasicNewsRecipe): timefmt = ' [%d %b %Y]' max_articles_per_feed = 50 no_stylesheets = True - language = 'de' - encoding = 'utf-8' + language = 'de' remove_tags = [dict(id='outside-advert'), @@ -39,8 +38,14 @@ class cdnet(BasicNewsRecipe): dict(id='bookmarkTools'), dict(id='printTools'), dict(id='header-nextNews'), + dict(id='commentsBox'), + dict(id='showComments'), + dict(id='footer'), dict(id=''), dict(name='div', attrs={'class':'pyjama'}), + dict(name='div', attrs={'class':'basicCentral'}), + dict(name='li', attrs={'class':'simplePagination-previous'}), + dict(name='form', attrs={'id':'commentForm'}), dict(name='href', attrs={'class':'comment'}), dict(name='div', attrs={'class':'greyBoxR clearfix'}), dict(name='div', attrs={'class':'greyBoxL clearfix'}),