mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Switch to using lit2oeb to explode LIT files.
This commit is contained in:
parent
f5bcc609b3
commit
4dff7ecf95
@ -10,7 +10,6 @@ import glob, sys, subprocess, tarfile, os, re, py_compile, shutil
|
||||
HOME = '/home/kovid'
|
||||
PYINSTALLER = os.path.expanduser('~/build/pyinstaller')
|
||||
CALIBREPREFIX = '___'
|
||||
CLIT = '/usr/bin/clit'
|
||||
PDFTOHTML = '/usr/bin/pdftohtml'
|
||||
LIBUNRAR = '/usr/lib/libunrar.so'
|
||||
QTDIR = '/usr/lib/qt4'
|
||||
@ -117,7 +116,7 @@ for f in glob.glob(os.path.join(CALIBREPLUGINS, '*.so.*')):
|
||||
binaries += [(os.path.basename(f), f, 'BINARY')]
|
||||
|
||||
print 'Adding external programs...'
|
||||
binaries += [('clit', CLIT, 'BINARY'), ('pdftohtml', PDFTOHTML, 'BINARY'),
|
||||
binaries += [('pdftohtml', PDFTOHTML, 'BINARY'),
|
||||
('libunrar.so', LIBUNRAR, 'BINARY')]
|
||||
|
||||
print 'Adding external libraries...'
|
||||
|
@ -243,12 +243,6 @@ _check_symlinks_prescript()
|
||||
self.add_plugins()
|
||||
|
||||
|
||||
print
|
||||
print 'Adding clit'
|
||||
os.link(os.path.expanduser('~/clit'), os.path.join(frameworks_dir, 'clit'))
|
||||
print
|
||||
print 'Adding unrtf'
|
||||
os.link(os.path.expanduser('~/unrtf'), os.path.join(frameworks_dir, 'unrtf'))
|
||||
print
|
||||
print 'Adding pdftohtml'
|
||||
os.link(os.path.expanduser('~/pdftohtml'), os.path.join(frameworks_dir, 'pdftohtml'))
|
||||
|
@ -10,7 +10,6 @@ QT_DIR = 'C:\\Qt\\4.4.0'
|
||||
DEVCON = 'C:\\devcon\\i386\\devcon.exe'
|
||||
LIBUSB_DIR = 'C:\\libusb'
|
||||
LIBUNRAR = 'C:\\Program Files\\UnrarDLL\\unrar.dll'
|
||||
CLIT = 'C:\\clit\\clit.exe'
|
||||
PDFTOHTML = 'C:\\pdftohtml\\pdftohtml.exe'
|
||||
IMAGEMAGICK_DIR = 'C:\\ImageMagick'
|
||||
FONTCONFIG_DIR = 'C:\\fontconfig'
|
||||
@ -105,8 +104,6 @@ class BuildEXE(py2exe.build_exe.py2exe):
|
||||
shutil.copyfile(DEVCON, os.path.join(tdir, os.path.basename(DEVCON)))
|
||||
print '\tAdding unrar'
|
||||
shutil.copyfile(LIBUNRAR, os.path.join(PY2EXE_DIR, os.path.basename(LIBUNRAR)))
|
||||
print '\tAdding ConvertLIT'
|
||||
shutil.copyfile(CLIT, os.path.join(PY2EXE_DIR, os.path.basename(CLIT)))
|
||||
print '\tAdding pdftohtml'
|
||||
shutil.copyfile(PDFTOHTML, os.path.join(PY2EXE_DIR, os.path.basename(PDFTOHTML)))
|
||||
print '\tAdding ImageMagick'
|
||||
|
@ -98,7 +98,7 @@ CONFIG += x86 ppc
|
||||
|
||||
|
||||
def build_extension(self, ext):
|
||||
self.inplace = True
|
||||
self.inplace = True # Causes extensions to be built in the source tree
|
||||
if not isinstance(ext, PyQtExtension):
|
||||
return _build_ext.build_extension(self, ext)
|
||||
|
||||
|
@ -3,19 +3,12 @@ __copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
|
||||
import os, sys, shutil, glob, logging
|
||||
from tempfile import mkdtemp
|
||||
from subprocess import Popen, PIPE
|
||||
from calibre.ebooks.lrf import option_parser as lrf_option_parser
|
||||
from calibre.ebooks.lit.reader import LitReader
|
||||
from calibre.ebooks import ConversionError
|
||||
from calibre.ebooks.lrf.html.convert_from import process_file as html_process_file
|
||||
from calibre.ebooks.metadata.opf import OPFReader
|
||||
from calibre import isosx, __appname__, setup_cli_handlers, islinux
|
||||
|
||||
CLIT = 'clit'
|
||||
if isosx and hasattr(sys, 'frameworks_dir'):
|
||||
CLIT = os.path.join(getattr(sys, 'frameworks_dir'), CLIT)
|
||||
if islinux and getattr(sys, 'frozen_path', False):
|
||||
CLIT = os.path.join(getattr(sys, 'frozen_path'), 'clit')
|
||||
from calibre import __appname__, setup_cli_handlers
|
||||
|
||||
def option_parser():
|
||||
parser = lrf_option_parser(
|
||||
@ -24,11 +17,9 @@ _('''Usage: %prog [options] mybook.lit
|
||||
|
||||
%prog converts mybook.lit to mybook.lrf''')
|
||||
)
|
||||
parser.add_option('--lit2oeb', default=False, dest='lit2oeb', action='store_true',
|
||||
help='Use the new lit2oeb to convert lit files instead of convertlit.')
|
||||
return parser
|
||||
|
||||
def generate_html2(pathtolit, logger):
|
||||
def generate_html(pathtolit, logger):
|
||||
if not os.access(pathtolit, os.R_OK):
|
||||
raise ConversionError, 'Cannot read from ' + pathtolit
|
||||
tdir = mkdtemp(prefix=__appname__+'_'+'lit2oeb_')
|
||||
@ -37,36 +28,13 @@ def generate_html2(pathtolit, logger):
|
||||
lr.extract_content(tdir)
|
||||
return tdir
|
||||
|
||||
def generate_html(pathtolit, logger):
|
||||
if isinstance(pathtolit, unicode):
|
||||
pathtolit = pathtolit.encode(sys.getfilesystemencoding())
|
||||
if not os.access(pathtolit, os.R_OK):
|
||||
raise ConversionError, 'Cannot read from ' + pathtolit
|
||||
tdir = mkdtemp(prefix=__appname__+'_')
|
||||
os.rmdir(tdir)
|
||||
cmd = [CLIT, pathtolit, '%s'%(tdir+os.sep)]
|
||||
logger.debug(repr(cmd))
|
||||
p = Popen(cmd, stderr=PIPE, stdout=PIPE)
|
||||
stdout = p.stdout.read()
|
||||
err = p.stderr.read()
|
||||
logger.info(p.stdout.read())
|
||||
ret = p.wait()
|
||||
if ret != 0:
|
||||
if os.path.exists(tdir) and os.path.isdir(tdir):
|
||||
shutil.rmtree(tdir)
|
||||
if 'keys.txt' in unicode(err)+unicode(stdout):
|
||||
raise ConversionError('This lit file is protected by DRM. You must first use the ConvertLIT program to remove the DRM. Doing so may be illegal, and so %s does not do this, nor does it provide instructions on how to do it.'%(__appname__,))
|
||||
raise ConversionError, err
|
||||
return tdir
|
||||
|
||||
def process_file(path, options, logger=None):
|
||||
if logger is None:
|
||||
level = logging.DEBUG if options.verbose else logging.INFO
|
||||
logger = logging.getLogger('lit2lrf')
|
||||
setup_cli_handlers(logger, level)
|
||||
lit = os.path.abspath(os.path.expanduser(path))
|
||||
tdir = generate_html2(lit, logger) if getattr(options, 'lit2oeb', False) \
|
||||
else generate_html(lit, logger)
|
||||
tdir = generate_html(lit, logger)
|
||||
try:
|
||||
opf = glob.glob(os.path.join(tdir, '*.opf'))
|
||||
if opf:
|
||||
|
@ -35,7 +35,6 @@ class Distribution(object):
|
||||
('ImageMagick', '6.3.5', 'imagemagick', 'imagemagick', 'ImageMagick'),
|
||||
('xdg-utils', '1.0.2', 'xdg-utils', 'xdg-utils', 'xdg-utils'),
|
||||
('dbus-python', '0.82.2', 'dbus-python', 'python-dbus', 'dbus-python'),
|
||||
('convertlit', '1.8', 'convertlit', None, None),
|
||||
('lxml', '1.3.3', 'lxml', 'python-lxml', 'python-lxml'),
|
||||
('help2man', '1.36.4', 'help2man', 'help2man', 'help2man'),
|
||||
]
|
||||
@ -49,10 +48,7 @@ class Distribution(object):
|
||||
'fedora':'Fedora 8', 'debian':'Debian Sid', 'generic': 'Generic Unix'}
|
||||
|
||||
MANUAL_MAP = {
|
||||
'ubuntu' : '<li>You will have to install <a href="">convertlit</a> manually to be able to convert LIT files.</li>',
|
||||
'fedora' : '''<li>You have to upgrade Qt to at least 4.3.1 and PyQt to at least 4.3.1</li>'''\
|
||||
'''<li>You will have to install <a href="">convertlit</a> manually to be able to convert LIT files.</li>''',
|
||||
'debian' : '<li>Add the following to /etc/apt/sources.list<pre class="wiki">deb http://www.debian-multimedia.org sid main</pre>Then<pre class="wiki">apt-get install clit</pre></li>',
|
||||
'fedora' : '''<li>You have to upgrade Qt to at least 4.4.0 and PyQt to at least 4.4.2</li>''',
|
||||
}
|
||||
|
||||
def __init__(self, os):
|
||||
|
@ -220,7 +220,7 @@ def stage_one():
|
||||
os.mkdir('build')
|
||||
shutil.rmtree('docs')
|
||||
os.mkdir('docs')
|
||||
subprocess.call('python setup.py develop', shell=True)
|
||||
check_call('python setup.py build', shell=True)
|
||||
check_call('sudo python setup.py develop', shell=True)
|
||||
check_call('make', shell=True)
|
||||
tag_release()
|
||||
|
Loading…
x
Reference in New Issue
Block a user