mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Add udev logic to setup.py should make post-installation on linux uneccessary.
Add --link-exclude to html2lrf
This commit is contained in:
parent
599ee22515
commit
3ef78e8e1a
14
setup.py
14
setup.py
@ -271,6 +271,7 @@ setup(
|
|||||||
'gui_scripts' : [ 'prs500-gui = libprs500.gui.main:main']
|
'gui_scripts' : [ 'prs500-gui = libprs500.gui.main:main']
|
||||||
},
|
},
|
||||||
zip_safe = True,
|
zip_safe = True,
|
||||||
|
install_requires = ['sqlalchemy >= 0.3.7'],
|
||||||
description =
|
description =
|
||||||
"""
|
"""
|
||||||
Library to interface with the Sony Portable Reader 500
|
Library to interface with the Sony Portable Reader 500
|
||||||
@ -321,3 +322,16 @@ else:
|
|||||||
import PyQt4.QtCore
|
import PyQt4.QtCore
|
||||||
if PyQt4.QtCore.PYQT_VERSION < 0x40101:
|
if PyQt4.QtCore.PYQT_VERSION < 0x40101:
|
||||||
print "WARNING: The GUI needs PyQt >= 4.1.1"
|
print "WARNING: The GUI needs PyQt >= 4.1.1"
|
||||||
|
|
||||||
|
import os
|
||||||
|
if os.access('/etc/udev/rules.d', os.W_OK):
|
||||||
|
from subprocess import check_call
|
||||||
|
print 'Trying to setup udev rules...',
|
||||||
|
sys.stdout.flush()
|
||||||
|
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'''
|
||||||
|
)
|
||||||
|
udev.close()
|
||||||
|
check_call('udevstart', shell=True)
|
||||||
|
print 'success'
|
||||||
|
@ -238,7 +238,8 @@ class HTMLConverter(object):
|
|||||||
font_delta=0, verbose=False, cover=None,
|
font_delta=0, verbose=False, cover=None,
|
||||||
max_link_levels=sys.maxint, link_level=0,
|
max_link_levels=sys.maxint, link_level=0,
|
||||||
is_root=True, baen=False, chapter_detection=True,
|
is_root=True, baen=False, chapter_detection=True,
|
||||||
chapter_regex=re.compile('chapter|book|appendix', re.IGNORECASE)):
|
chapter_regex=re.compile('chapter|book|appendix', re.IGNORECASE),
|
||||||
|
link_exclude=re.compile('')):
|
||||||
'''
|
'''
|
||||||
Convert HTML file at C{path} and add it to C{book}. After creating
|
Convert HTML file at C{path} and add it to C{book}. After creating
|
||||||
the object, you must call L{self.process_links} on it to create the links and
|
the object, you must call L{self.process_links} on it to create the links and
|
||||||
@ -268,6 +269,7 @@ class HTMLConverter(object):
|
|||||||
the start of a chapter
|
the start of a chapter
|
||||||
@type chapter_detection: C{bool}
|
@type chapter_detection: C{bool}
|
||||||
@param chapter_regex: The compiled regular expression used to search for chapter titles
|
@param chapter_regex: The compiled regular expression used to search for chapter titles
|
||||||
|
@param link_exclude: Compiled regex. Matching hrefs are ignored.
|
||||||
'''
|
'''
|
||||||
# Defaults for various formatting tags
|
# Defaults for various formatting tags
|
||||||
self.css = dict(
|
self.css = dict(
|
||||||
@ -289,6 +291,7 @@ class HTMLConverter(object):
|
|||||||
self.dpi = dpi #: The DPI of the intended display device
|
self.dpi = dpi #: The DPI of the intended display device
|
||||||
self.chapter_detection = chapter_detection #: Flag to toggle chapter detection
|
self.chapter_detection = chapter_detection #: Flag to toggle chapter detection
|
||||||
self.chapter_regex = chapter_regex #: Regex used to search for chapter titles
|
self.chapter_regex = chapter_regex #: Regex used to search for chapter titles
|
||||||
|
self.link_exclude = link_exclude #: Ignore matching hrefs
|
||||||
self.scaled_images = {} #: Temporary files with scaled version of images
|
self.scaled_images = {} #: Temporary files with scaled version of images
|
||||||
self.max_link_levels = max_link_levels #: Number of link levels to process recursively
|
self.max_link_levels = max_link_levels #: Number of link levels to process recursively
|
||||||
self.link_level = link_level #: Current link level
|
self.link_level = link_level #: Current link level
|
||||||
@ -428,8 +431,6 @@ class HTMLConverter(object):
|
|||||||
if not self.top.parent:
|
if not self.top.parent:
|
||||||
raise ConversionError, 'Could not parse ' + self.file_name
|
raise ConversionError, 'Could not parse ' + self.file_name
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def get_text(self, tag):
|
def get_text(self, tag):
|
||||||
css = self.tag_css(tag)
|
css = self.tag_css(tag)
|
||||||
@ -512,7 +513,8 @@ class HTMLConverter(object):
|
|||||||
max_link_levels=self.max_link_levels,
|
max_link_levels=self.max_link_levels,
|
||||||
is_root = False, baen=self.baen,
|
is_root = False, baen=self.baen,
|
||||||
chapter_detection=self.chapter_detection,
|
chapter_detection=self.chapter_detection,
|
||||||
chapter_regex=self.chapter_regex)
|
chapter_regex=self.chapter_regex,
|
||||||
|
link_exclude=self.link_exclude)
|
||||||
HTMLConverter.processed_files[path] = self.files[path]
|
HTMLConverter.processed_files[path] = self.files[path]
|
||||||
except Exception:
|
except Exception:
|
||||||
print >>sys.stderr, 'Unable to process', path
|
print >>sys.stderr, 'Unable to process', path
|
||||||
@ -730,7 +732,7 @@ class HTMLConverter(object):
|
|||||||
self.current_page.append(target)
|
self.current_page.append(target)
|
||||||
|
|
||||||
self.targets[tag['name']] = target
|
self.targets[tag['name']] = target
|
||||||
elif tag.has_key('href'):
|
elif tag.has_key('href') and not self.link_exclude.match(tag['href']):
|
||||||
purl = urlparse(tag['href'])
|
purl = urlparse(tag['href'])
|
||||||
path = purl[2]
|
path = purl[2]
|
||||||
if path and os.path.splitext(path)[1][1:].lower() in \
|
if path and os.path.splitext(path)[1][1:].lower() in \
|
||||||
@ -1002,7 +1004,8 @@ def process_file(path, options):
|
|||||||
cover=cpath, max_link_levels=options.link_levels,
|
cover=cpath, max_link_levels=options.link_levels,
|
||||||
baen=options.baen,
|
baen=options.baen,
|
||||||
chapter_detection=options.chapter_detection,
|
chapter_detection=options.chapter_detection,
|
||||||
chapter_regex=re.compile(options.chapter_regex, re.IGNORECASE))
|
chapter_regex=re.compile(options.chapter_regex, re.IGNORECASE),
|
||||||
|
link_exclude=re.compile(options.link_exclude))
|
||||||
conv.process_links()
|
conv.process_links()
|
||||||
oname = options.output
|
oname = options.output
|
||||||
if not oname:
|
if not oname:
|
||||||
@ -1049,6 +1052,9 @@ def main():
|
|||||||
default='chapter|book|appendix',
|
default='chapter|book|appendix',
|
||||||
help='''The regular expression used to detect chapter titles.'''
|
help='''The regular expression used to detect chapter titles.'''
|
||||||
'''It is searched for in heading tags. Default is chapter|book|appendix''')
|
'''It is searched for in heading tags. Default is chapter|book|appendix''')
|
||||||
|
parser.add_option('--link-exclude', dest='link_exclude', default='',
|
||||||
|
help='''A regular expression. <a> tags whoose href '''
|
||||||
|
'''matches will be ignored''')
|
||||||
options, args = parser.parse_args()
|
options, args = parser.parse_args()
|
||||||
if len(args) != 1:
|
if len(args) != 1:
|
||||||
parser.print_help()
|
parser.print_help()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user