~ubuntu-branches/ubuntu/karmic/calibre/karmic

« back to all changes in this revision

Viewing changes to src/calibre/web/feeds/recipes/__init__.py

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2009-07-30 12:49:41 UTC
  • mfrom: (1.3.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20090730124941-qjdsmri25zt8zocn
Tags: 0.6.3+dfsg-0ubuntu1
* New upstream release. Please see http://calibre.kovidgoyal.net/new_in_6/
  for the list of new features and changes.
* remove_postinstall.patch: Update for new version.
* build_debug.patch: Does not apply any more, disable for now. Might not be
  necessary any more.
* debian/copyright: Fix reference to versionless GPL.
* debian/rules: Drop obsolete dh_desktop call.
* debian/rules: Add workaround for weird Python 2.6 setuptools behaviour of
  putting compiled .so files into src/calibre/plugins/calibre/plugins
  instead of src/calibre/plugins.
* debian/rules: Drop hal fdi moving, new upstream version does not use hal
  any more. Drop hal dependency, too.
* debian/rules: Install udev rules into /lib/udev/rules.d.
* Add debian/calibre.preinst: Remove unmodified
  /etc/udev/rules.d/95-calibre.rules on upgrade.
* debian/control: Bump Python dependencies to 2.6, since upstream needs
  it now.

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
           'demorgen_be', 'de_standaard', 'ap', 'barrons', 'chr_mon', 'cnn', 'faznet',
16
16
           'jpost', 'jutarnji', 'nasa', 'reuters', 'spiegelde', 'wash_post', 'zeitde',
17
17
           'blic', 'novosti', 'danas', 'vreme', 'times_online', 'the_scotsman',
18
 
           'nytimes_sub', 'security_watch', 'cyberpresse', 'st_petersburg_times',
 
18
           'nytimes_sub', 'nytimes', 'security_watch', 'cyberpresse', 'st_petersburg_times',
19
19
           'clarin', 'financial_times', 'heise', 'le_monde', 'harpers', 'science_aas',
20
20
           'science_news', 'the_nation', 'lrb', 'harpers_full', 'liberation',
21
21
           'linux_magazine', 'telegraph_uk', 'utne', 'sciencedaily', 'forbes',
44
44
           'stackoverflow', 'telepolis_artikel', 'zaobao', 'usnews',
45
45
           'straitstimes', 'index_hu', 'pcworld_hu', 'hrt', 'rts',
46
46
           'h1', 'h2', 'h3', 'phd_comics', 'woz_die', 'elektrolese',
47
 
           'climate_progress', 'carta',
 
47
           'climate_progress', 'carta', 'slashdot', 'publico',
 
48
           'the_budget_fashionista', 'elperiodico_catalan',
 
49
           'elperiodico_spanish', 'expansion_spanish', 'lavanguardia',
 
50
           'marca', 'kellog_faculty', 'kellog_insight', 'noaa',
 
51
           'theeconomictimes_india', '7dias', 'buenosaireseconomico',
 
52
           'diagonales', 'miradasalsur', 'newsweek_argentina', 'veintitres',
 
53
           'gva_be', 'hln', 'tijd', 'degentenaar', 'inquirer_net', 'uncrate',
 
54
           'fastcompany', 'accountancyage', 'laprensa_hn', 'latribuna',
 
55
           'eltiempo_hn', 'slate',
48
56
          )]
49
57
 
 
58
 
50
59
import re, imp, inspect, time, os
51
60
from calibre.web.feeds.news import BasicNewsRecipe, CustomIndexRecipe, AutomaticNewsRecipe
52
 
from calibre.ebooks.lrf.web.profiles import DefaultProfile, FullContentProfile
53
61
from calibre.ebooks.BeautifulSoup import BeautifulSoup
54
62
from calibre.path import path
55
63
from calibre.ptempfile import PersistentTemporaryDirectory
56
64
from calibre import __appname__, english_sort
57
65
 
58
 
basic_recipes = (BasicNewsRecipe, AutomaticNewsRecipe, CustomIndexRecipe, DefaultProfile, FullContentProfile)
 
66
basic_recipes = (BasicNewsRecipe, AutomaticNewsRecipe, CustomIndexRecipe)
59
67
basic_recipe_names = (i.__name__ for i in basic_recipes)
60
68
 
61
69
 
86
94
    Compile the code in src and return the first object that is a recipe or profile.
87
95
    @param src: Python source code
88
96
    @type src: string
89
 
    @return: Recipe/Profile class or None, if no such class was found in C{src}
 
97
    @return: Recipe class or None, if no such class was found in C{src}
90
98
    '''
91
99
    global _tdir, _crep
92
100
    if _tdir is None or not os.path.exists(_tdir):
100
108
    src = re.sub(r'from __future__.*', '', src)
101
109
    f = open(temp, 'wb')
102
110
    src = 'from %s.web.feeds.news import BasicNewsRecipe, AutomaticNewsRecipe\n'%__appname__ + src
103
 
    src = 'from %s.ebooks.lrf.web.profiles import DefaultProfile, FullContentProfile\n'%__appname__ + src
104
111
    src = '# coding: utf-8\n' + src
105
112
    src = 'from __future__ import with_statement\n' + src
106
113
 
111
118
    module = imp.load_module(temp.namebase, *module)
112
119
    classes = inspect.getmembers(module,
113
120
            lambda x : inspect.isclass(x) and \
114
 
                issubclass(x, (DefaultProfile, BasicNewsRecipe)) and \
 
121
                issubclass(x, (BasicNewsRecipe,)) and \
115
122
                x not in basic_recipes)
116
123
    if not classes:
117
124
        return None
122
129
def get_builtin_recipe(title):
123
130
    '''
124
131
    Return a builtin recipe/profile class whose title == C{title} or None if no such
125
 
    recipe exists. Also returns a flag that is True iff the found recipe is really
126
 
    an old-style Profile.
 
132
    recipe exists.
127
133
 
128
134
    @type title: string
129
 
    @rtype: class or None, boolean
 
135
    @rtype: class or None
130
136
    '''
131
137
    for r in recipes:
132
138
        if r.title == title: