version 0.3.110

This commit is contained in:
Kovid Goyal 2007-09-15 17:43:24 +00:00
parent e4b5027cee
commit 3fdc9ad89d
9 changed files with 108 additions and 10 deletions

View File

@ -33,6 +33,7 @@ entry_points = {
'web2lrf = libprs500.ebooks.lrf.web.convert_from:main',\
'pdf2lrf = libprs500.ebooks.lrf.pdf.convert_from:main',\
'any2lrf = libprs500.ebooks.lrf.any.convert_from:main',\
'lrf2lrs = libprs500.ebooks.lrf.lrs.convert_to:main',\
'libprs500-beta = libprs500.gui2.main:main',\
],
'gui_scripts' : [ APPNAME+' = libprs500.gui.main:main']

View File

@ -13,7 +13,7 @@
## with this program; if not, write to the Free Software Foundation, Inc.,
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
''' E-book management software'''
__version__ = "0.3.109"
__version__ = "0.3.110"
__docformat__ = "epytext"
__author__ = "Kovid Goyal <kovid@kovidgoyal.net>"
__appname__ = 'libprs500'

View File

@ -21,7 +21,6 @@ from base64 import b64decode as decode
from base64 import b64encode as encode
import time, re
from libprs500.devices.errors import ProtocolError
from libprs500.devices.interface import BookList as _BookList
MIME_MAP = { \

View File

@ -0,0 +1,82 @@
## Copyright (C) 2007 Kovid Goyal kovid@kovidgoyal.net
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 2 of the License, or
## (at your option) any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License along
## with this program; if not, write to the Free Software Foundation, Inc.,
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
import tempfile, shutil, os
from libprs500.ebooks.lrf.web import build_index, parse_feeds
RSS = 'http://economist.com/rss/'
TITLES = [
'The world this week',
'Letters',
'Briefings',
'Special reports',
'Britain',
'Europe',
'United States',
'The Americas',
'Middle East and Africa',
'Asia',
'International',
'Business',
'Finance and economics',
'Science and technology',
'Books and arts',
'Indicators'
]
from libprs500 import __appname__, iswindows, browser
from libprs500.ebooks.BeautifulSoup import BeautifulSoup
def print_version(url):
return url.replace('displaystory', 'PrinterFriendly').replace('&fsrc=RSS', '')
def get_feeds(browser):
src = browser.open(RSS).read()
soup = BeautifulSoup(src)
feeds = []
for ul in soup.findAll('ul'):
lis = ul.findAll('li')
try:
title, link = lis[0], lis[1]
except IndexError:
continue
title = title.string
if title:
title = title.strip()
if title not in TITLES:
continue
a = link.find('a')
feeds.append((title, a['href'].strip()))
return feeds
def initialize(profile):
profile['temp dir'] = tempfile.mkdtemp(prefix=__appname__+'_')
profile['browser'] = browser()
feeds = get_feeds(profile['browser'])
articles = parse_feeds(feeds, profile['browser'], print_version, max_articles_per_feed=20)
index = build_index('The Economist', articles, profile['temp dir'])
profile['url'] = 'file:'+ ('' if iswindows else '//') + index
profile['timefmt'] = ' [%d %b %Y]'
profile['max_recursions'] = 3
profile['title'] = 'The Economist'
profile.pop('browser') # Needed as for some reason using the same browser instance causes timeouts
def finalize(profile):
return
if os.path.isdir(profile['temp dir']):
shutil.rmtree(profile['temp dir'])

View File

@ -13,7 +13,7 @@
## with this program; if not, write to the Free Software Foundation, Inc.,
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
'''Profiles for known websites.'''
import time, re
import re
from libprs500.ebooks.lrf.web.newsweek import initialize as newsweek_initialize
from libprs500.ebooks.lrf.web.newsweek import finalize as newsweek_finalize
@ -21,6 +21,8 @@ from libprs500.ebooks.lrf.web.nytimes import initialize as nytimes_initialize
from libprs500.ebooks.lrf.web.nytimes import finalize as nytimes_finalize
from libprs500.ebooks.lrf.web.bbc import initialize as bbc_initialize
from libprs500.ebooks.lrf.web.bbc import finalize as bbc_finalize
from libprs500.ebooks.lrf.web.economist import initialize as economist_initialize
from libprs500.ebooks.lrf.web.economist import finalize as economist_finalize
profiles = {
@ -106,6 +108,18 @@ profiles = {
]
],
},
'economist' : {
'initialize' : economist_initialize,
'finalize' : economist_finalize,
'preprocess_regexps' :
[ (re.compile(i[0], re.IGNORECASE | re.DOTALL), i[1]) for i in
[
# Remove advert
(r'<noscript.*?</noscript>', lambda match: ''),
]
],
},
}
for key in profiles.keys():

View File

@ -25,7 +25,7 @@ def get_metadata(stream):
title = os.path.splitext(os.path.basename(stream.name))[0]
else:
title = 'Unknown'
mi = MetaInformation(title, 'Unknown')
mi = MetaInformation(title, ['Unknown'])
stream.seek(0)
try:
info = PdfFileReader(stream).getDocumentInfo()
@ -41,6 +41,7 @@ def get_metadata(stream):
if info.subject:
mi.category = info.subject
except Exception, err:
raise
print >>sys.stderr, 'Couldn\'t read metadata from pdf: %s with error %s'%(mi.title, str(err))
return mi

View File

@ -142,7 +142,7 @@ class MetadataSingleDialog(QDialog, Ui_MetadataSingleDialog):
au = self.db.authors(row)
self.authors.setText(au if au else '')
aus = self.db.author_sort(row)
self.author_sort.setText(aus)
self.author_sort.setText(aus if aus else '')
pub = self.db.publisher(row)
self.publisher.setText(pub if pub else '')
tags = self.db.tags(row)

View File

@ -174,6 +174,7 @@ def setup_udev_rules():
udev = open('/etc/udev/rules.d/95-libprs500.rules', 'w')
udev.write('''# Sony Reader PRS-500\n'''
'''BUS=="usb", SYSFS{idProduct}=="029b", SYSFS{idVendor}=="054c", MODE="660", GROUP="plugdev"\n'''
'''BUS=="usb", SYSFS{idProduct}=="029b", SYSFS{idVendor}=="054c", MODE="660", GROUP="usb"\n'''
)
udev.close()
try: