Pull from trunk

This commit is contained in:
Kovid Goyal 2009-03-09 13:15:08 -07:00
commit 8b2e754595
11 changed files with 133 additions and 76 deletions

View File

@ -2,7 +2,7 @@ __license__ = 'GPL v3'
__copyright__ = '2008, Kovid Goyal kovid@kovidgoyal.net' __copyright__ = '2008, Kovid Goyal kovid@kovidgoyal.net'
__docformat__ = 'restructuredtext en' __docformat__ = 'restructuredtext en'
__appname__ = 'calibre' __appname__ = 'calibre'
__version__ = '0.4.143' __version__ = '0.5.0'
__author__ = "Kovid Goyal <kovid@kovidgoyal.net>" __author__ = "Kovid Goyal <kovid@kovidgoyal.net>"
''' '''
Various run time constants. Various run time constants.

View File

@ -143,6 +143,7 @@ class PageProcessor(list):
MagickRotateImage(wand, pw, -90) MagickRotateImage(wand, pw, -90)
# 25 percent fuzzy trim? # 25 percent fuzzy trim?
if not self.opts.disable_trim:
MagickTrimImage(wand, 25*65535/100) MagickTrimImage(wand, 25*65535/100)
MagickSetImagePage(wand, 0,0,0,0) #Clear page after trim, like a "+repage" MagickSetImagePage(wand, 0,0,0,0) #Clear page after trim, like a "+repage"
# Do the Photoshop "Auto Levels" equivalent # Do the Photoshop "Auto Levels" equivalent
@ -303,6 +304,9 @@ def config(defaults=None,output_format='lrf'):
help=_('Maintain picture aspect ratio. Default is to fill the screen.')) help=_('Maintain picture aspect ratio. Default is to fill the screen.'))
c.add_opt('dont_sharpen', ['-s', '--disable-sharpen'], default=False, c.add_opt('dont_sharpen', ['-s', '--disable-sharpen'], default=False,
help=_('Disable sharpening.')) help=_('Disable sharpening.'))
c.add_opt('disable_trim', ['--disable-trim'], default=False,
help=_('Disable trimming of comic pages. For some comics, '
'trimming might remove content as well as borders.'))
c.add_opt('landscape', ['-l', '--landscape'], default=False, c.add_opt('landscape', ['-l', '--landscape'], default=False,
help=_("Don't split landscape images into two portrait images")) help=_("Don't split landscape images into two portrait images"))
c.add_opt('wide', ['-w', '--wide-aspect'], default=False, c.add_opt('wide', ['-w', '--wide-aspect'], default=False,

View File

@ -29,6 +29,7 @@ class LrsParser(object):
self.logger = logger self.logger = logger
src = stream.read() src = stream.read()
self.soup = BeautifulStoneSoup(xml_to_unicode(src)[0], self.soup = BeautifulStoneSoup(xml_to_unicode(src)[0],
convertEntities=BeautifulStoneSoup.XML_ENTITIES,
selfClosingTags=self.SELF_CLOSING_TAGS) selfClosingTags=self.SELF_CLOSING_TAGS)
self.objects = {} self.objects = {}
for obj in self.soup.findAll(objid=True): for obj in self.soup.findAll(objid=True):

View File

@ -112,7 +112,8 @@ key is the account key you generate after signing up for a free account from isb
default=None, help=_('The title of the book to search for.')) default=None, help=_('The title of the book to search for.'))
parser.add_option('-p', '--publisher', default=None, dest='publisher', parser.add_option('-p', '--publisher', default=None, dest='publisher',
help=_('The publisher of the book to search for.')) help=_('The publisher of the book to search for.'))
parser.add_option('--verbose', default=False, action='store_true', help=_('Verbose processing')) parser.add_option('-v', '--verbose', default=False,
action='store_true', help=_('Verbose processing'))
return parser return parser

View File

@ -1,154 +1,162 @@
<ui version="4.0" > <?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Dialog</class> <class>Dialog</class>
<widget class="QDialog" name="Dialog" > <widget class="QDialog" name="Dialog">
<property name="geometry" > <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>646</width> <width>646</width>
<height>468</height> <height>503</height>
</rect> </rect>
</property> </property>
<property name="windowTitle" > <property name="windowTitle">
<string>Dialog</string> <string>Dialog</string>
</property> </property>
<property name="windowIcon" > <property name="windowIcon">
<iconset resource="../images.qrc" > <iconset resource="../images.qrc">
<normaloff>:/images/convert.svg</normaloff>:/images/convert.svg</iconset> <normaloff>:/images/convert.svg</normaloff>:/images/convert.svg</iconset>
</property> </property>
<layout class="QGridLayout" name="gridLayout" > <layout class="QGridLayout" name="gridLayout">
<item row="0" column="0" > <item row="0" column="0">
<widget class="QLabel" name="title_label" > <widget class="QLabel" name="title_label">
<property name="text" > <property name="text">
<string>&amp;Title:</string> <string>&amp;Title:</string>
</property> </property>
<property name="buddy" > <property name="buddy">
<cstring>opt_title</cstring> <cstring>opt_title</cstring>
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="1" > <item row="0" column="1">
<widget class="QLineEdit" name="opt_title" /> <widget class="QLineEdit" name="opt_title"/>
</item> </item>
<item row="1" column="0" > <item row="1" column="0">
<widget class="QLabel" name="author_label" > <widget class="QLabel" name="author_label">
<property name="text" > <property name="text">
<string>&amp;Author(s):</string> <string>&amp;Author(s):</string>
</property> </property>
<property name="buddy" > <property name="buddy">
<cstring>opt_author</cstring> <cstring>opt_author</cstring>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="1" > <item row="1" column="1">
<widget class="QLineEdit" name="opt_author" /> <widget class="QLineEdit" name="opt_author"/>
</item> </item>
<item row="2" column="0" > <item row="2" column="0">
<widget class="QLabel" name="label_3" > <widget class="QLabel" name="label_3">
<property name="text" > <property name="text">
<string>&amp;Number of Colors:</string> <string>&amp;Number of Colors:</string>
</property> </property>
<property name="buddy" > <property name="buddy">
<cstring>opt_colors</cstring> <cstring>opt_colors</cstring>
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="1" > <item row="2" column="1">
<widget class="QSpinBox" name="opt_colors" > <widget class="QSpinBox" name="opt_colors">
<property name="minimum" > <property name="minimum">
<number>8</number> <number>8</number>
</property> </property>
<property name="maximum" > <property name="maximum">
<number>3200000</number> <number>3200000</number>
</property> </property>
<property name="singleStep" > <property name="singleStep">
<number>8</number> <number>8</number>
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="0" > <item row="3" column="0">
<widget class="QLabel" name="label_4" > <widget class="QLabel" name="label_4">
<property name="text" > <property name="text">
<string>&amp;Profile:</string> <string>&amp;Profile:</string>
</property> </property>
<property name="buddy" > <property name="buddy">
<cstring>opt_profile</cstring> <cstring>opt_profile</cstring>
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="1" > <item row="3" column="1">
<widget class="QComboBox" name="opt_profile" /> <widget class="QComboBox" name="opt_profile"/>
</item> </item>
<item row="4" column="0" > <item row="4" column="0">
<widget class="QCheckBox" name="opt_dont_normalize" > <widget class="QCheckBox" name="opt_dont_normalize">
<property name="text" > <property name="text">
<string>Disable &amp;normalize</string> <string>Disable &amp;normalize</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="5" column="0" > <item row="5" column="0">
<widget class="QCheckBox" name="opt_keep_aspect_ratio" > <widget class="QCheckBox" name="opt_keep_aspect_ratio">
<property name="text" > <property name="text">
<string>Keep &amp;aspect ratio</string> <string>Keep &amp;aspect ratio</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="6" column="0" > <item row="6" column="0">
<widget class="QCheckBox" name="opt_dont_sharpen" > <widget class="QCheckBox" name="opt_dont_sharpen">
<property name="text" > <property name="text">
<string>Disable &amp;Sharpening</string> <string>Disable &amp;Sharpening</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="8" column="0" > <item row="9" column="0">
<widget class="QCheckBox" name="opt_landscape" > <widget class="QCheckBox" name="opt_landscape">
<property name="text" > <property name="text">
<string>&amp;Landscape</string> <string>&amp;Landscape</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="10" column="0" > <item row="11" column="0">
<widget class="QCheckBox" name="opt_no_sort" > <widget class="QCheckBox" name="opt_no_sort">
<property name="text" > <property name="text">
<string>Don't so&amp;rt</string> <string>Don't so&amp;rt</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="12" column="1" > <item row="13" column="1">
<widget class="QDialogButtonBox" name="buttonBox" > <widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation" > <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="standardButtons" > <property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property> </property>
</widget> </widget>
</item> </item>
<item row="9" column="0" > <item row="10" column="0">
<widget class="QCheckBox" name="opt_right2left" > <widget class="QCheckBox" name="opt_right2left">
<property name="text" > <property name="text">
<string>&amp;Right to left</string> <string>&amp;Right to left</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="11" column="0" > <item row="12" column="0">
<widget class="QCheckBox" name="opt_despeckle" > <widget class="QCheckBox" name="opt_despeckle">
<property name="text" > <property name="text">
<string>De&amp;speckle</string> <string>De&amp;speckle</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="7" column="0" > <item row="8" column="0">
<widget class="QCheckBox" name="opt_wide" > <widget class="QCheckBox" name="opt_wide">
<property name="text" > <property name="text">
<string>&amp;Wide</string> <string>&amp;Wide</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="7" column="0">
<widget class="QCheckBox" name="opt_disable_trim">
<property name="text">
<string>Disable &amp;Trimming</string>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
<resources> <resources>
<include location="../images.qrc" /> <include location="../images.qrc"/>
</resources> </resources>
<connections> <connections>
<connection> <connection>
@ -157,11 +165,11 @@
<receiver>Dialog</receiver> <receiver>Dialog</receiver>
<slot>accept()</slot> <slot>accept()</slot>
<hints> <hints>
<hint type="sourcelabel" > <hint type="sourcelabel">
<x>248</x> <x>248</x>
<y>254</y> <y>254</y>
</hint> </hint>
<hint type="destinationlabel" > <hint type="destinationlabel">
<x>157</x> <x>157</x>
<y>274</y> <y>274</y>
</hint> </hint>
@ -173,11 +181,11 @@
<receiver>Dialog</receiver> <receiver>Dialog</receiver>
<slot>reject()</slot> <slot>reject()</slot>
<hints> <hints>
<hint type="sourcelabel" > <hint type="sourcelabel">
<x>316</x> <x>316</x>
<y>260</y> <y>260</y>
</hint> </hint>
<hint type="destinationlabel" > <hint type="destinationlabel">
<x>286</x> <x>286</x>
<y>274</y> <y>274</y>
</hint> </hint>

View File

@ -34,6 +34,8 @@ What formats does |app| support conversion to/from?
| | | | | | | | | | | |
| | ODT | ✔ | ✔ | ✔ | | | ODT | ✔ | ✔ | ✔ |
| | | | | | | | | | | |
| | FB2 | ✔ | ✔ | ✔ |
| | | | | |
| | HTML | ✔ | ✔ | ✔ | | | HTML | ✔ | ✔ | ✔ |
| | | | | | | | | | | |
| **Input formats** | CBR | ✔ | ✔ | ✔ | | **Input formats** | CBR | ✔ | ✔ | ✔ |

View File

@ -33,7 +33,7 @@ recipe_modules = ['recipe_' + r for r in (
'la_republica', 'physics_today', 'chicago_tribune', 'e_novine', 'la_republica', 'physics_today', 'chicago_tribune', 'e_novine',
'al_jazeera', 'winsupersite', 'borba', 'courrierinternational', 'al_jazeera', 'winsupersite', 'borba', 'courrierinternational',
'lamujerdemivida', 'soldiers', 'theonion', 'news_times', 'lamujerdemivida', 'soldiers', 'theonion', 'news_times',
'el_universal', 'mediapart', 'wikinews_en', 'el_universal', 'mediapart', 'wikinews_en', 'ecogeek',
)] )]
import re, imp, inspect, time, os import re, imp, inspect, time, os

View File

@ -0,0 +1,31 @@
#!/usr/bin/env python
__license__ = 'GPL v3'
__copyright__ = '2009, Darko Miletic <darko.miletic at gmail.com>'
'''
EcoGeek.org
'''
from calibre.web.feeds.news import BasicNewsRecipe
class EcoGeek(BasicNewsRecipe):
title = 'EcoGeek'
__author__ = 'Darko Miletic'
description = 'EcoGeek - Technology for the Environment Blog Feed'
publisher = 'EcoGeek'
language = _('English')
category = 'news, ecology, blog'
oldest_article = 7
max_articles_per_feed = 100
no_stylesheets = True
use_embedded_content = True
html2lrf_options = [
'--comment', description
, '--category', category
, '--publisher', publisher
]
html2epub_options = 'publisher="' + publisher + '"\ncomments="' + description + '"\ntags="' + category + '"'
feeds = [(u'Posts', u'http://feeds2.feedburner.com/EcoGeek')]

View File

@ -70,10 +70,14 @@ class NYTimesMobile(BasicNewsRecipe):
def find_articles(self, root): def find_articles(self, root):
for a in root.xpath('//a[@accesskey]'): for a in root.xpath('//a[@accesskey]'):
href = a.get('href') href = a.get('href')
if href.startswith('http://'):
url = href
else:
url = 'http://mobile.nytimes.com/article' + href[href.find('?'):]+'&single=1',
yield { yield {
'title': a.text.strip(), 'title': a.text.strip(),
'date' : '', 'date' : '',
'url' : 'http://mobile.nytimes.com/article' + href[href.find('?'):]+'&single=1', 'url' : url,
'description': '', 'description': '',
} }

View File

@ -75,7 +75,9 @@ class NYTimes(BasicNewsRecipe):
dict(title=title, url=url, date=pubdate, dict(title=title, url=url, date=pubdate,
description=description, description=description,
content='')) content=''))
ans = self.sort_index_by(ans, {'The Front Page':-1, 'Dining In, Dining Out':1, 'Obituaries':2}) ans = self.sort_index_by(ans, {'The Front Page':-1,
'Dining In, Dining Out':1,
'Obituaries':2})
ans = [(key, articles[key]) for key in ans if articles.has_key(key)] ans = [(key, articles[key]) for key in ans if articles.has_key(key)]
return ans return ans

View File

@ -45,3 +45,7 @@ class USAToday(BasicNewsRecipe):
def print_version(self, url): def print_version(self, url):
return 'http://www.printthis.clickability.com/pt/printThis?clickMap=printThis&fb=Y&url=' + url return 'http://www.printthis.clickability.com/pt/printThis?clickMap=printThis&fb=Y&url=' + url
def postprocess_html(self, soup, first_fetch):
for t in soup.findAll(['table', 'tr', 'td']):
t.name = 'div'
return soup