mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
IGN:Integrate lit2oeb
This commit is contained in:
parent
318de321f1
commit
349edbe472
10
Makefile
10
Makefile
@ -2,7 +2,7 @@ PYTHON = python
|
||||
|
||||
all : plugins gui2 translations resources
|
||||
|
||||
plugins : src/calibre/plugins pictureflow
|
||||
plugins : src/calibre/plugins pictureflow lzx
|
||||
|
||||
src/calibre/plugins:
|
||||
mkdir -p src/calibre/plugins
|
||||
@ -39,10 +39,10 @@ pictureflow :
|
||||
rm -rf src/calibre/gui2/pictureflow/.build rm -rf src/calibre/gui2/pictureflow/PyQt/.build
|
||||
|
||||
lzx :
|
||||
mkdir -p src/calibre/plugins && rm -f src/calibre/plugins/*pictureflow* && \
|
||||
cd src/calibre/utils/lzx && mkdir .build && cd .build && \
|
||||
${PYTHON} ../configure.py && make && cd - && \
|
||||
cp src/calibre/utils/lzx/.build/lzx.so src/calibre/plugins/ && \
|
||||
mkdir -p src/calibre/plugins && rm -f src/calibre/plugins/lzx.so && \
|
||||
cd src/calibre/utils/lzx && \
|
||||
${PYTHON} setup.py build --build-base=.build && cd - && \
|
||||
cp src/calibre/utils/lzx/.build/lib*/lzx.so src/calibre/plugins/ && \
|
||||
rm -rf src/calibre/utils/lzx/.build/
|
||||
|
||||
pot :
|
||||
|
@ -50,6 +50,25 @@ class BuildEXE(py2exe.build_exe.py2exe):
|
||||
</trustInfo>
|
||||
</assembly>
|
||||
'''
|
||||
def build_distutil_plugins(self):
|
||||
plugins = [
|
||||
('lzx', os.path.join('utils', 'lzx')),
|
||||
]
|
||||
for name, path in plugins:
|
||||
print 'Building plugin', name
|
||||
path = os.path.abspath(os.path.join('src', 'calibre', path))
|
||||
cwd = os.getcwd()
|
||||
dd = os.path.join(cwd, self.dist_dir)
|
||||
os.chdir(path)
|
||||
try:
|
||||
if os.path.exists('.build'):
|
||||
shutil.rmtree('.build')
|
||||
subprocess.check_call(('python', 'setup.py', 'build', '--build-base', '.build'))
|
||||
plugin = os.path.abspath(glob.glob('.build\\lib*\\%s.pyd'%name)[0])
|
||||
shutil.copyfile(plugin, os.path.join(dd, os.path.basename(plugin)))
|
||||
finally:
|
||||
os.chdir(cwd)
|
||||
|
||||
def build_plugins(self):
|
||||
cwd = os.getcwd()
|
||||
dd = os.path.join(cwd, self.dist_dir)
|
||||
@ -80,6 +99,7 @@ class BuildEXE(py2exe.build_exe.py2exe):
|
||||
if not os.path.exists(self.dist_dir):
|
||||
os.makedirs(self.dist_dir)
|
||||
print 'Building custom plugins...'
|
||||
self.build_distutil_plugins()
|
||||
self.build_plugins()
|
||||
py2exe.build_exe.py2exe.run(self)
|
||||
qtsvgdll = None
|
||||
@ -189,7 +209,7 @@ def main(args=sys.argv):
|
||||
'calibre.ebooks.lrf.feeds.*',
|
||||
'lxml', 'lxml._elementpath', 'genshi',
|
||||
'path', 'pydoc', 'IPython.Extensions.*',
|
||||
'calibre.web.feeds.recipes.*',
|
||||
'calibre.web.feeds.recipes.*',
|
||||
'PyQt4.QtWebKit', 'PyQt4.QtNetwork',
|
||||
],
|
||||
'packages' : ['PIL'],
|
||||
|
@ -171,6 +171,28 @@ _check_symlinks_prescript()
|
||||
subprocess.check_call(['/usr/bin/install_name_tool', '-change', '/Library/Frameworks/Python.framework/Versions/2.5/Python', '@executable_path/../Frameworks/Python.framework/Versions/2.5/Python', f])
|
||||
|
||||
|
||||
def build_distutils_plugins(self):
|
||||
plugins = [
|
||||
('lzx', os.path.join('utils', 'lzx')),
|
||||
]
|
||||
files = []
|
||||
env = {'PATH':os.environ['PATH']}
|
||||
for name, path in plugins:
|
||||
print 'Building plugin', name
|
||||
path = os.path.abspath(os.path.join('src', 'calibre', path))
|
||||
cwd = os.getcwd()
|
||||
os.chdir(path)
|
||||
try:
|
||||
if os.path.exists('.build'):
|
||||
shutil.rmtree('.build')
|
||||
subprocess.check_call((sys.executable, 'setup.py', 'build', '--build-base', '.build'),
|
||||
env=env)
|
||||
plugin = os.path.abspath(glob.glob('.build/lib*/%s.so'%name)[0])
|
||||
files.append([plugin, os.path.basename(plugin)])
|
||||
finally:
|
||||
os.chdir(cwd)
|
||||
return files
|
||||
|
||||
def build_plugins(self):
|
||||
cwd = os.getcwd()
|
||||
qmake = '/Users/kovid/qt/bin/qmake'
|
||||
@ -205,6 +227,7 @@ _check_symlinks_prescript()
|
||||
|
||||
|
||||
def run(self):
|
||||
plugin_files = self.build_distutils_plugins()
|
||||
py2app.run(self)
|
||||
resource_dir = os.path.join(self.dist_dir,
|
||||
APPNAME + '.app', 'Contents', 'Resources')
|
||||
@ -227,7 +250,7 @@ _check_symlinks_prescript()
|
||||
os.chmod(path, stat.S_IXUSR|stat.S_IXGRP|stat.S_IXOTH|stat.S_IREAD\
|
||||
|stat.S_IWUSR|stat.S_IROTH|stat.S_IRGRP)
|
||||
self.add_qt_plugins()
|
||||
plugin_files = self.build_plugins()
|
||||
plugin_files += self.build_plugins()
|
||||
|
||||
print
|
||||
print 'Adding clit'
|
||||
|
@ -563,22 +563,6 @@ def strftime(fmt, t=time.localtime()):
|
||||
except:
|
||||
return unicode(result, 'utf-8', 'replace')
|
||||
|
||||
if islinux and not getattr(sys, 'frozen', False):
|
||||
import pkg_resources
|
||||
plugins = pkg_resources.resource_filename(__appname__, 'plugins')
|
||||
sys.path.insert(1, plugins)
|
||||
|
||||
if iswindows and hasattr(sys, 'frozen'):
|
||||
sys.path.insert(1, os.path.dirname(sys.executable))
|
||||
|
||||
try:
|
||||
import pictureflow
|
||||
pictureflowerror = ''
|
||||
except Exception, err:
|
||||
pictureflow = None
|
||||
pictureflowerror = str(err)
|
||||
|
||||
|
||||
def entity_to_unicode(match, exceptions=[], encoding='cp1252'):
|
||||
'''
|
||||
@param match: A match object such that '&'+match.group(1)';' is the entity.
|
||||
@ -621,3 +605,23 @@ if isosx:
|
||||
for font in fonts:
|
||||
exec 'from calibre.ebooks.lrf.fonts.liberation.'+font+' import font_data'
|
||||
open(os.path.join(fdir, font+'.ttf'), 'wb').write(font_data)
|
||||
|
||||
if islinux and not getattr(sys, 'frozen', False):
|
||||
import pkg_resources
|
||||
plugins = pkg_resources.resource_filename(__appname__, 'plugins')
|
||||
sys.path.insert(1, plugins)
|
||||
|
||||
if iswindows and getattr(sys, 'frozen', False):
|
||||
sys.path.insert(1, os.path.dirname(sys.executable))
|
||||
|
||||
|
||||
plugins = {}
|
||||
for plugin in ['pictureflow', 'lzx']:
|
||||
try:
|
||||
p, err = __import__(plugin), ''
|
||||
except Exception, err:
|
||||
p = None
|
||||
err = str(err)
|
||||
plugins[plugin] = (p, err)
|
||||
|
||||
|
||||
|
@ -9,17 +9,12 @@ __copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net> ' \
|
||||
|
||||
import sys, struct, cStringIO, os
|
||||
import functools
|
||||
import codecs
|
||||
from itertools import repeat
|
||||
|
||||
from calibre import relpath
|
||||
from calibre.ebooks.metadata import MetaInformation
|
||||
from calibre.ebooks.metadata.opf import OPFReader
|
||||
from calibre.ebooks.lit import LitError
|
||||
from calibre.ebooks.lit.maps import OPF_MAP, HTML_MAP
|
||||
import calibre.ebooks.lit.mssha1 as mssha1
|
||||
import calibre.ebooks.lit.msdes as msdes
|
||||
import calibre.utils.lzx as lzx
|
||||
from calibre import plugins
|
||||
lzx, lxzerror = plugins['lzx']
|
||||
|
||||
OPF_DECL = """<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE package
|
||||
@ -783,7 +778,7 @@ def option_parser():
|
||||
help=_('Output directory. Defaults to current directory.'))
|
||||
parser.add_option(
|
||||
'--verbose', default=False, action='store_true',
|
||||
help='Useful for debugging.')
|
||||
help=_('Useful for debugging.'))
|
||||
return parser
|
||||
|
||||
def main(args=sys.argv):
|
||||
|
@ -12,7 +12,8 @@ import sys, os
|
||||
from PyQt4.QtGui import QImage, QSizePolicy
|
||||
from PyQt4.QtCore import Qt, QSize, SIGNAL, QObject
|
||||
|
||||
from calibre import pictureflow, Settings
|
||||
from calibre import Settings, plugins
|
||||
pictureflow, pictureflowerror = plugins['pictureflow']
|
||||
|
||||
if pictureflow is not None:
|
||||
class EmptyImageList(pictureflow.FlowImages):
|
||||
|
@ -10,8 +10,7 @@ from PyQt4.QtGui import QPixmap, QColor, QPainter, QMenu, QIcon, QMessageBox, \
|
||||
from PyQt4.QtSvg import QSvgRenderer
|
||||
|
||||
from calibre import __version__, __appname__, islinux, sanitize_file_name, \
|
||||
Settings, pictureflowerror, iswindows, isosx,\
|
||||
preferred_encoding
|
||||
Settings, iswindows, isosx, preferred_encoding
|
||||
from calibre.ptempfile import PersistentTemporaryFile
|
||||
from calibre.ebooks.metadata.meta import get_metadata, get_filename_pat, set_filename_pat
|
||||
from calibre.devices.errors import FreeSpaceError
|
||||
@ -21,7 +20,7 @@ from calibre.gui2 import APP_UID, warning_dialog, choose_files, error_dialog, \
|
||||
pixmap_to_data, choose_dir, ORG_NAME, \
|
||||
set_sidebar_directories, \
|
||||
SingleApplication, Application, available_height, max_available_height
|
||||
from calibre.gui2.cover_flow import CoverFlow, DatabaseImages
|
||||
from calibre.gui2.cover_flow import CoverFlow, DatabaseImages, pictureflowerror
|
||||
from calibre.library.database import LibraryDatabase
|
||||
from calibre.gui2.update import CheckForUpdates
|
||||
from calibre.gui2.main_window import MainWindow, option_parser
|
||||
|
@ -161,6 +161,7 @@ def setup_completion(fatal_errors):
|
||||
from calibre.gui2.lrf_renderer.main import option_parser as lrfviewerop
|
||||
from calibre.ebooks.lrf.pdf.reflow import option_parser as pdfhtmlop
|
||||
from calibre.ebooks.mobi.reader import option_parser as mobioeb
|
||||
from calibre.ebooks.lit.reader import option_parser as lit2oeb
|
||||
from calibre.web.feeds.main import option_parser as feeds2disk
|
||||
from calibre.web.feeds.recipes import titles as feed_titles
|
||||
from calibre.ebooks.lrf.feeds.convert_from import option_parser as feeds2lrf
|
||||
@ -195,6 +196,7 @@ def setup_completion(fatal_errors):
|
||||
f.write(opts_and_exts('lrfviewer', lrfviewerop, ['lrf']))
|
||||
f.write(opts_and_exts('pdfrelow', pdfhtmlop, ['pdf']))
|
||||
f.write(opts_and_exts('mobi2oeb', mobioeb, ['mobi', 'prc']))
|
||||
f.write(opts_and_exts('lit2oeb', lit2oeb, ['lit']))
|
||||
f.write(opts_and_words('feeds2disk', feeds2disk, feed_titles))
|
||||
f.write(opts_and_words('feeds2lrf', feeds2lrf, feed_titles))
|
||||
f.write('''
|
||||
|
@ -1248,7 +1248,7 @@ msgstr "Actieve opdrachten"
|
||||
|
||||
#: /home/kovid/work/calibre/src/calibre/gui2/dialogs/jobs_ui.py:39
|
||||
msgid "&Stop selected job"
|
||||
msgstr "%Stop de geselecteerde opdracht"
|
||||
msgstr "&Stop de geselecteerde opdracht"
|
||||
|
||||
#: /home/kovid/work/calibre/src/calibre/gui2/dialogs/lrf_single.py:54
|
||||
#: /home/kovid/work/calibre/src/calibre/gui2/dialogs/lrf_single.py:291
|
||||
@ -1471,7 +1471,7 @@ msgstr ""
|
||||
#: /home/kovid/work/calibre/src/calibre/gui2/dialogs/metadata_bulk_ui.py:132
|
||||
#: /home/kovid/work/calibre/src/calibre/gui2/dialogs/metadata_single_ui.py:274
|
||||
msgid "&Series:"
|
||||
msgstr "%Series:"
|
||||
msgstr "&Series:"
|
||||
|
||||
#: /home/kovid/work/calibre/src/calibre/gui2/dialogs/lrf_single_ui.py:526
|
||||
#: /home/kovid/work/calibre/src/calibre/gui2/dialogs/lrf_single_ui.py:527
|
||||
@ -1510,7 +1510,7 @@ msgstr "Toegevoegde Lettertypen"
|
||||
|
||||
#: /home/kovid/work/calibre/src/calibre/gui2/dialogs/lrf_single_ui.py:535
|
||||
msgid "&Serif:"
|
||||
msgstr "%Serif:"
|
||||
msgstr "&Serif:"
|
||||
|
||||
#: /home/kovid/work/calibre/src/calibre/gui2/dialogs/lrf_single_ui.py:536
|
||||
msgid "S&ans-serif:"
|
||||
@ -2450,7 +2450,7 @@ msgstr "Opslaan op schijf in een enkele folder"
|
||||
|
||||
#: /home/kovid/work/calibre/src/calibre/gui2/main.py:152
|
||||
msgid "Save only %s format to disk"
|
||||
msgstr "Bewaar alleen %formaat op schijf"
|
||||
msgstr "Bewaar alleen %s formaat op schijf"
|
||||
|
||||
#: /home/kovid/work/calibre/src/calibre/gui2/main.py:155
|
||||
#: /home/kovid/work/calibre/src/calibre/gui2/main_ui.py:281
|
||||
@ -3177,6 +3177,8 @@ msgstr ""
|
||||
"\n"
|
||||
"commando is een van de volgende:\n"
|
||||
" %s\n"
|
||||
" \n"
|
||||
"For help on an individual command: %%prog command --help\n"
|
||||
|
||||
#: /home/kovid/work/calibre/src/calibre/parallel.py:321
|
||||
msgid "Could not launch worker process."
|
||||
|
15
src/calibre/utils/lzx/setup.py
Normal file
15
src/calibre/utils/lzx/setup.py
Normal file
@ -0,0 +1,15 @@
|
||||
#!/usr/bin/env python
|
||||
__license__ = 'GPL v3'
|
||||
__copyright__ = '2008, Kovid Goyal kovid@kovidgoyal.net'
|
||||
__docformat__ = 'restructuredtext en'
|
||||
|
||||
'''
|
||||
Build the lzx decompressor extension
|
||||
'''
|
||||
from distutils.core import setup, Extension
|
||||
|
||||
setup(name="lzx", version="1.0",
|
||||
ext_modules=[Extension('lzx',
|
||||
sources=['lzxmodule.c', 'lzxd.c'],
|
||||
include_dirs=['.'])])
|
||||
|
Loading…
x
Reference in New Issue
Block a user