mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Sync to trunk.
This commit is contained in:
commit
aa48bc9763
@ -1,6 +1,5 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
||||||
from __future__ import with_statement
|
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
|
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||||
@ -39,13 +38,19 @@ def _run():
|
|||||||
import os, sys, site
|
import os, sys, site
|
||||||
sys.frozen = 'macosx_app'
|
sys.frozen = 'macosx_app'
|
||||||
base = os.environ['RESOURCEPATH']
|
base = os.environ['RESOURCEPATH']
|
||||||
sys.frameworks_dir = os.path.join(os.path.dirname(base, 'Frameworks'))
|
sys.frameworks_dir = os.path.join(os.path.dirname(base), 'Frameworks')
|
||||||
sys.new_app_bundle = True
|
sys.new_app_bundle = True
|
||||||
site.addsitedir(base)
|
site.addsitedir(base)
|
||||||
site.addsitedir(os.path.join(base, 'Python', 'site-packages'))
|
site.addsitedir(os.path.join(base, 'Python', 'site-packages'))
|
||||||
exe = os.environ.get('CALIBRE_LAUNCH_MODULE', 'calibre.gui2.main')
|
exe = os.environ.get('CALIBRE_LAUNCH_MODULE', 'calibre.gui2.main')
|
||||||
exe = os.path.join(base, 'Python', 'site-packages', *exe.split('.'))
|
exe = os.path.join(base, 'Python', 'site-packages', *exe.split('.'))
|
||||||
|
exe += '.py'
|
||||||
sys.argv[0] = __file__ = exe
|
sys.argv[0] = __file__ = exe
|
||||||
|
argv = os.environ.get('CALIBRE_LAUNCH_ARGV', None)
|
||||||
|
if argv is not None:
|
||||||
|
import cPickle
|
||||||
|
argv = cPickle.loads(argv)
|
||||||
|
sys.argv[1:] = argv
|
||||||
execfile(exe, globals(), globals())
|
execfile(exe, globals(), globals())
|
||||||
|
|
||||||
_run()
|
_run()
|
||||||
|
@ -5,7 +5,7 @@ __copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
|
|||||||
__docformat__ = 'restructuredtext en'
|
__docformat__ = 'restructuredtext en'
|
||||||
|
|
||||||
|
|
||||||
import os, sys
|
import os, sys, cPickle
|
||||||
|
|
||||||
ENV = {}##ENV##
|
ENV = {}##ENV##
|
||||||
MODULE = ''##MODULE##
|
MODULE = ''##MODULE##
|
||||||
@ -18,13 +18,16 @@ resources_dir = os.path.join(base_dir, 'Resources')
|
|||||||
frameworks_dir = os.path.join(base_dir, 'Frameworks')
|
frameworks_dir = os.path.join(base_dir, 'Frameworks')
|
||||||
exe_dir = os.path.join(base_dir, 'MacOS')
|
exe_dir = os.path.join(base_dir, 'MacOS')
|
||||||
base_name = os.path.splitext(name)[0]
|
base_name = os.path.splitext(name)[0]
|
||||||
python = os.path.join(base_dir, 'MacOS', 'calibre')
|
python = os.path.join(base_dir, 'MacOS', 'Python')
|
||||||
|
|
||||||
for key, val in ENV.items():
|
for key, val in ENV.items():
|
||||||
if val.startswith('@exec'):
|
if val.startswith('@exec'):
|
||||||
ENV[key] = os.path.normpath(val.replace('@executable_path', exe_dir))
|
ENV[key] = os.path.normpath(val.replace('@executable_path', exe_dir))
|
||||||
ENV['CALIBRE_LAUNCH_MODULE'] = MODULE
|
ENV['CALIBRE_LAUNCH_MODULE'] = MODULE
|
||||||
|
ENV['CALIBRE_LAUNCH_ARGV'] = cPickle.dumps(sys.argv[1:], -1)
|
||||||
|
ENV['RESOURCEPATH'] = resources_dir
|
||||||
os.environ.update(ENV)
|
os.environ.update(ENV)
|
||||||
args = [path] + sys.argv[1:]
|
launcher = os.path.join(resources_dir, 'launcher.py')
|
||||||
|
args = ['-OO', launcher]
|
||||||
os.execv(python, args)
|
os.execv(python, args)
|
||||||
|
|
||||||
|
@ -864,9 +864,10 @@ static int py2app_main(int argc, char * const *argv, char * const *envp) {
|
|||||||
if (!getApplicationName()) return report_error(ERR_NONAME);
|
if (!getApplicationName()) return report_error(ERR_NONAME);
|
||||||
pyLocations = (CFArrayRef)getKey("PyRuntimeLocations");
|
pyLocations = (CFArrayRef)getKey("PyRuntimeLocations");
|
||||||
if (!pyLocations) return report_error(ERR_PYRUNTIMELOCATIONS);
|
if (!pyLocations) return report_error(ERR_PYRUNTIMELOCATIONS);
|
||||||
|
printf("1111111\n;");
|
||||||
pyLocation = findPyLocation(pyLocations);
|
pyLocation = findPyLocation(pyLocations);
|
||||||
if (!pyLocation) return report_error(ERR_NOPYTHONRUNTIME);
|
if (!pyLocation) return report_error(ERR_NOPYTHONRUNTIME);
|
||||||
|
printf("2222222\n");
|
||||||
setExecutablePath();
|
setExecutablePath();
|
||||||
setResourcePath();
|
setResourcePath();
|
||||||
/* check for ':' in path, not compatible with Python due to Py_GetPath */
|
/* check for ':' in path, not compatible with Python due to Py_GetPath */
|
||||||
@ -895,7 +896,7 @@ static int py2app_main(int argc, char * const *argv, char * const *envp) {
|
|||||||
xCFStringGetCString(pyLocation, buf, sizeof(buf), kCFStringEncodingUTF8);
|
xCFStringGetCString(pyLocation, buf, sizeof(buf), kCFStringEncodingUTF8);
|
||||||
py_dylib = dlopen(buf, PYMACAPP_DYLD_FLAGS);
|
py_dylib = dlopen(buf, PYMACAPP_DYLD_FLAGS);
|
||||||
if (py_dylib == NULL) return report_linkEdit_error();
|
if (py_dylib == NULL) return report_linkEdit_error();
|
||||||
|
printf("3333333\n");
|
||||||
#define LOOKUP_SYMBOL(NAME) \
|
#define LOOKUP_SYMBOL(NAME) \
|
||||||
tmpSymbol = dlsym(py_dylib, # NAME)
|
tmpSymbol = dlsym(py_dylib, # NAME)
|
||||||
#define LOOKUP_DEFINEADDRESS(NAME, ADDRESS) \
|
#define LOOKUP_DEFINEADDRESS(NAME, ADDRESS) \
|
||||||
|
@ -26,6 +26,7 @@ ENV = dict(
|
|||||||
PYTHONIOENCODING='utf-8:replace',
|
PYTHONIOENCODING='utf-8:replace',
|
||||||
PYTHONPATH='@executable_path/../Resources/Python/site-packages',
|
PYTHONPATH='@executable_path/../Resources/Python/site-packages',
|
||||||
PYTHONHOME='@executable_path/../Resources/Python',
|
PYTHONHOME='@executable_path/../Resources/Python',
|
||||||
|
PYTHONOPTIMIZE='2',
|
||||||
QT_PLUGIN_PATH='@executable_path'
|
QT_PLUGIN_PATH='@executable_path'
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -66,6 +67,16 @@ def strip_files(files, argv_max=(256 * 1024)):
|
|||||||
for args in flips:
|
for args in flips:
|
||||||
flipwritable(*args)
|
flipwritable(*args)
|
||||||
|
|
||||||
|
def flush(func):
|
||||||
|
def ff(*args, **kwargs):
|
||||||
|
sys.stdout.flush()
|
||||||
|
sys.stderr.flush()
|
||||||
|
ret = func(*args, **kwargs)
|
||||||
|
sys.stdout.flush()
|
||||||
|
sys.stderr.flush()
|
||||||
|
return ret
|
||||||
|
return ff
|
||||||
|
|
||||||
class Py2App(object):
|
class Py2App(object):
|
||||||
|
|
||||||
FID = '@executable_path/../Frameworks'
|
FID = '@executable_path/../Frameworks'
|
||||||
@ -75,7 +86,16 @@ class Py2App(object):
|
|||||||
self.contents_dir = join(self.build_dir, 'Contents')
|
self.contents_dir = join(self.build_dir, 'Contents')
|
||||||
self.resources_dir = join(self.contents_dir, 'Resources')
|
self.resources_dir = join(self.contents_dir, 'Resources')
|
||||||
self.frameworks_dir = join(self.contents_dir, 'Frameworks')
|
self.frameworks_dir = join(self.contents_dir, 'Frameworks')
|
||||||
|
self.version_info = '.'.join(map(str, sys.version_info[:2]))
|
||||||
self.to_strip = []
|
self.to_strip = []
|
||||||
|
self.warnings = []
|
||||||
|
|
||||||
|
def warn(self, *args):
|
||||||
|
self.warnings.append(args)
|
||||||
|
prefix = '' if args and args[0].startswith('WARNING:') else 'WARNING: '
|
||||||
|
sys.stdout.write(prefix+' '.join(args)+'\n')
|
||||||
|
sys.stdout.flush()
|
||||||
|
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
self.create_skeleton()
|
self.create_skeleton()
|
||||||
@ -103,26 +123,43 @@ class Py2App(object):
|
|||||||
self.strip_files()
|
self.strip_files()
|
||||||
self.create_launchers()
|
self.create_launchers()
|
||||||
|
|
||||||
return self.makedmg(self.build_dir, APPNAME+'-'+VERSION+'-x86_64')
|
ret = self.makedmg(self.build_dir, APPNAME+'-'+VERSION+'-x86_64')
|
||||||
|
sys.stdout.flush()
|
||||||
|
sys.stderr.flush()
|
||||||
|
|
||||||
|
print '\nThere were', len(self.warnings), 'warnings'
|
||||||
|
for w in list(self.warnings):
|
||||||
|
print
|
||||||
|
self.warn(*w)
|
||||||
|
return ret
|
||||||
|
|
||||||
|
@flush
|
||||||
def create_launchers(self):
|
def create_launchers(self):
|
||||||
launcher = join(os.path.dirname(__file__), 'launcher.py')
|
print '\nCreating launchers'
|
||||||
|
all_names = basenames['console'] + basenames['gui']
|
||||||
|
all_modules = main_modules['console'] + main_modules['gui']
|
||||||
|
launcher = join(os.path.dirname(__file__), 'loader.py')
|
||||||
launcher = open(launcher, 'rb').read()
|
launcher = open(launcher, 'rb').read()
|
||||||
launcher = launcher.replace('{}##ENV##', repr(ENV))
|
launcher = launcher.replace('{}##ENV##', repr(ENV))
|
||||||
os.mkdir(join(self.resources_dir, 'loaders'))
|
os.mkdir(join(self.resources_dir, 'loaders'))
|
||||||
for module, basename in zip(main_modules, basenames):
|
for basename, module in zip(all_names, all_modules):
|
||||||
|
py_file = join('src', *module.split('.'))+'.py'
|
||||||
|
shutil.copy2(py_file, join(self.resources_dir, 'Python',
|
||||||
|
'site-packages', *module.split('.'))+'.py')
|
||||||
raw = launcher.replace("''##MODULE##", repr(module))
|
raw = launcher.replace("''##MODULE##", repr(module))
|
||||||
path = join(self.resources_dir, 'loaders', basename)
|
path = join(self.resources_dir, 'loaders', basename)
|
||||||
open(path, 'wb').write(raw)
|
open(path, 'wb').write(raw)
|
||||||
os.chmod(path, stat.S_IXUSR|stat.S_IXGRP|stat.S_IXOTH|stat.S_IREAD\
|
os.chmod(path, stat.S_IXUSR|stat.S_IXGRP|stat.S_IXOTH|stat.S_IREAD\
|
||||||
|stat.S_IWUSR|stat.S_IROTH|stat.S_IRGRP)
|
|stat.S_IWUSR|stat.S_IROTH|stat.S_IRGRP)
|
||||||
|
|
||||||
|
@flush
|
||||||
def strip_files(self):
|
def strip_files(self):
|
||||||
print '\nStripping files...'
|
print '\nStripping files...'
|
||||||
strip_files(self.to_strip)
|
strip_files(self.to_strip)
|
||||||
|
|
||||||
|
@flush
|
||||||
def create_exe(self):
|
def create_exe(self):
|
||||||
|
print '\nCreating executable'
|
||||||
gcc = os.environ.get('CC', 'gcc')
|
gcc = os.environ.get('CC', 'gcc')
|
||||||
base = os.path.dirname(__file__)
|
base = os.path.dirname(__file__)
|
||||||
out = join(self.contents_dir, 'MacOS', 'calibre')
|
out = join(self.contents_dir, 'MacOS', 'calibre')
|
||||||
@ -130,25 +167,25 @@ class Py2App(object):
|
|||||||
'main.c'), '-o', out])
|
'main.c'), '-o', out])
|
||||||
self.to_strip.append(out)
|
self.to_strip.append(out)
|
||||||
|
|
||||||
|
@flush
|
||||||
def set_id(self, path_to_lib, new_id):
|
def set_id(self, path_to_lib, new_id):
|
||||||
old_mode = flipwritable(path_to_lib)
|
old_mode = flipwritable(path_to_lib)
|
||||||
subprocess.check_call(['install_name_tool', '-id', new_id, path_to_lib])
|
subprocess.check_call(['install_name_tool', '-id', new_id, path_to_lib])
|
||||||
if old_mode is not None:
|
if old_mode is not None:
|
||||||
flipwritable(path_to_lib, old_mode)
|
flipwritable(path_to_lib, old_mode)
|
||||||
|
|
||||||
|
@flush
|
||||||
def get_dependencies(self, path_to_lib):
|
def get_dependencies(self, path_to_lib):
|
||||||
raw = subprocess.Popen(['otool', '-L', path_to_lib],
|
raw = subprocess.Popen(['otool', '-L', path_to_lib],
|
||||||
stdout=subprocess.PIPE).stdout.read()
|
stdout=subprocess.PIPE).stdout.read()
|
||||||
for line in raw.splitlines():
|
for line in raw.splitlines():
|
||||||
if 'compatibility' not in line:
|
if 'compatibility' not in line or line.strip().endswith(':'):
|
||||||
continue
|
continue
|
||||||
idx = line.find('(')
|
idx = line.find('(')
|
||||||
path = line[:idx].strip()
|
path = line[:idx].strip()
|
||||||
bname = os.path.basename(path).partition('.')[0]
|
|
||||||
if bname in path_to_lib:
|
|
||||||
continue
|
|
||||||
yield path
|
yield path
|
||||||
|
|
||||||
|
@flush
|
||||||
def get_local_dependencies(self, path_to_lib):
|
def get_local_dependencies(self, path_to_lib):
|
||||||
for x in self.get_dependencies(path_to_lib):
|
for x in self.get_dependencies(path_to_lib):
|
||||||
for y in (SW+'/lib/', '/usr/local/lib/', SW+'/qt/lib/',
|
for y in (SW+'/lib/', '/usr/local/lib/', SW+'/qt/lib/',
|
||||||
@ -157,11 +194,13 @@ class Py2App(object):
|
|||||||
yield x, x[len(y):]
|
yield x, x[len(y):]
|
||||||
break
|
break
|
||||||
|
|
||||||
|
@flush
|
||||||
def change_dep(self, old_dep, new_dep, path_to_lib):
|
def change_dep(self, old_dep, new_dep, path_to_lib):
|
||||||
print '\tResolving dependency %s to'%old_dep, new_dep
|
print '\tResolving dependency %s to'%old_dep, new_dep
|
||||||
subprocess.check_call(['install_name_tool', '-change', old_dep, new_dep,
|
subprocess.check_call(['install_name_tool', '-change', old_dep, new_dep,
|
||||||
path_to_lib])
|
path_to_lib])
|
||||||
|
|
||||||
|
@flush
|
||||||
def fix_dependencies_in_lib(self, path_to_lib):
|
def fix_dependencies_in_lib(self, path_to_lib):
|
||||||
print '\nFixing dependencies in', path_to_lib
|
print '\nFixing dependencies in', path_to_lib
|
||||||
self.to_strip.append(path_to_lib)
|
self.to_strip.append(path_to_lib)
|
||||||
@ -174,7 +213,9 @@ class Py2App(object):
|
|||||||
if old_mode is not None:
|
if old_mode is not None:
|
||||||
flipwritable(path_to_lib, old_mode)
|
flipwritable(path_to_lib, old_mode)
|
||||||
|
|
||||||
|
@flush
|
||||||
def add_python_framework(self):
|
def add_python_framework(self):
|
||||||
|
print '\nAdding Python framework'
|
||||||
src = join(SW, 'python', 'Python.framework')
|
src = join(SW, 'python', 'Python.framework')
|
||||||
x = join(self.frameworks_dir, 'Python.framework')
|
x = join(self.frameworks_dir, 'Python.framework')
|
||||||
curr = os.path.realpath(join(src, 'Versions', 'Current'))
|
curr = os.path.realpath(join(src, 'Versions', 'Current'))
|
||||||
@ -185,7 +226,12 @@ class Py2App(object):
|
|||||||
shutil.copy2(join(curr, 'Python'), currd)
|
shutil.copy2(join(curr, 'Python'), currd)
|
||||||
self.set_id(join(currd, 'Python'),
|
self.set_id(join(currd, 'Python'),
|
||||||
self.FID+'/Python.framework/Versions/%s/Python'%basename(curr))
|
self.FID+'/Python.framework/Versions/%s/Python'%basename(curr))
|
||||||
|
python = '%s/python/Python.framework/Versions/%s/Resources/Python.app/Contents/MacOS/Python'\
|
||||||
|
% (SW, self.version_info)
|
||||||
|
shutil.copy2(python, join(self.contents_dir, 'MacOS'))
|
||||||
|
self.fix_dependencies_in_lib(join(self.contents_dir, 'MacOS', 'Python'))
|
||||||
|
|
||||||
|
@flush
|
||||||
def add_qt_frameworks(self):
|
def add_qt_frameworks(self):
|
||||||
for f in ('QtCore', 'QtGui', 'QtXml', 'QtNetwork', 'QtSvg', 'QtWebkit',
|
for f in ('QtCore', 'QtGui', 'QtXml', 'QtNetwork', 'QtSvg', 'QtWebkit',
|
||||||
'phonon'):
|
'phonon'):
|
||||||
@ -197,6 +243,7 @@ class Py2App(object):
|
|||||||
x = os.path.relpath(l, join(self.contents_dir, 'MacOS'))
|
x = os.path.relpath(l, join(self.contents_dir, 'MacOS'))
|
||||||
self.set_id(l, '@executable_path/'+x)
|
self.set_id(l, '@executable_path/'+x)
|
||||||
|
|
||||||
|
@flush
|
||||||
def add_qt_framework(self, f):
|
def add_qt_framework(self, f):
|
||||||
libname = f
|
libname = f
|
||||||
f = f+'.framework'
|
f = f+'.framework'
|
||||||
@ -210,6 +257,7 @@ class Py2App(object):
|
|||||||
self.set_id(lib, self.FID+'/'+rpath)
|
self.set_id(lib, self.FID+'/'+rpath)
|
||||||
self.fix_dependencies_in_lib(lib)
|
self.fix_dependencies_in_lib(lib)
|
||||||
|
|
||||||
|
@flush
|
||||||
def create_skeleton(self):
|
def create_skeleton(self):
|
||||||
c = join(self.build_dir, 'Contents')
|
c = join(self.build_dir, 'Contents')
|
||||||
for x in ('Frameworks', 'MacOS', 'Resources'):
|
for x in ('Frameworks', 'MacOS', 'Resources'):
|
||||||
@ -217,14 +265,16 @@ class Py2App(object):
|
|||||||
x = 'library.icns'
|
x = 'library.icns'
|
||||||
shutil.copyfile(join('icons', x), join(self.resources_dir, x))
|
shutil.copyfile(join('icons', x), join(self.resources_dir, x))
|
||||||
|
|
||||||
|
@flush
|
||||||
def add_calibre_plugins(self):
|
def add_calibre_plugins(self):
|
||||||
dest = join(self.frameworks_dir, 'plugins')
|
dest = join(self.frameworks_dir, 'plugins')
|
||||||
os.mkdir(dest)
|
os.mkdir(dest)
|
||||||
for f in glob.glob('src/calibre/plugins/*.so'):
|
for f in glob.glob('src/calibre/plugins/*.so'):
|
||||||
shutil.copy2(f, dest)
|
shutil.copy2(f, dest)
|
||||||
self.fix_dependencies_in_lib(join(dest, basename(f)))
|
self.fix_dependencies_in_lib(join(dest, basename(f)))
|
||||||
|
|
||||||
|
|
||||||
|
@flush
|
||||||
def create_plist(self):
|
def create_plist(self):
|
||||||
pl = dict(
|
pl = dict(
|
||||||
CFBundleDevelopmentRegion='English',
|
CFBundleDevelopmentRegion='English',
|
||||||
@ -236,7 +286,7 @@ class Py2App(object):
|
|||||||
CFBundleSignature='????',
|
CFBundleSignature='????',
|
||||||
CFBundleExecutable='calibre',
|
CFBundleExecutable='calibre',
|
||||||
LSMinimumSystemVersion='10.5.2',
|
LSMinimumSystemVersion='10.5.2',
|
||||||
PyRuntimeLocations=[self.FID+'/Python.framework/Versions/Current/Python'],
|
PyRuntimeLocations=[self.FID+'/Python.framework/Versions/%s/Python'%self.version_info],
|
||||||
LSRequiresNativeExecution=True,
|
LSRequiresNativeExecution=True,
|
||||||
NSAppleScriptEnabled=False,
|
NSAppleScriptEnabled=False,
|
||||||
NSHumanReadableCopyright='Copyright 2008, Kovid Goyal',
|
NSHumanReadableCopyright='Copyright 2008, Kovid Goyal',
|
||||||
@ -248,6 +298,7 @@ class Py2App(object):
|
|||||||
)
|
)
|
||||||
plistlib.writePlist(pl, join(self.contents_dir, 'Info.plist'))
|
plistlib.writePlist(pl, join(self.contents_dir, 'Info.plist'))
|
||||||
|
|
||||||
|
@flush
|
||||||
def install_dylib(self, path, set_id=True):
|
def install_dylib(self, path, set_id=True):
|
||||||
shutil.copy2(path, self.frameworks_dir)
|
shutil.copy2(path, self.frameworks_dir)
|
||||||
if set_id:
|
if set_id:
|
||||||
@ -255,25 +306,30 @@ class Py2App(object):
|
|||||||
self.FID+'/'+basename(path))
|
self.FID+'/'+basename(path))
|
||||||
self.fix_dependencies_in_lib(join(self.frameworks_dir, basename(path)))
|
self.fix_dependencies_in_lib(join(self.frameworks_dir, basename(path)))
|
||||||
|
|
||||||
|
@flush
|
||||||
def add_podofo(self):
|
def add_podofo(self):
|
||||||
print '\nAdding PoDoFo'
|
print '\nAdding PoDoFo'
|
||||||
pdf = join(SW, 'lib', 'libpodofo.0.6.99.dylib')
|
pdf = join(SW, 'lib', 'libpodofo.0.6.99.dylib')
|
||||||
self.install_dylib(pdf)
|
self.install_dylib(pdf)
|
||||||
|
|
||||||
|
@flush
|
||||||
def add_poppler(self):
|
def add_poppler(self):
|
||||||
print '\nAdding poppler'
|
print '\nAdding poppler'
|
||||||
for x in ('libpoppler.4.dylib', 'libpoppler-qt4.3.dylib'):
|
for x in ('libpoppler.4.dylib', 'libpoppler-qt4.3.dylib'):
|
||||||
self.install_dylib(os.path.join(SW, 'lib', x))
|
self.install_dylib(os.path.join(SW, 'lib', x))
|
||||||
self.install_dylib(os.path.join(SW, 'bin', 'pdftohtml'), False)
|
self.install_dylib(os.path.join(SW, 'bin', 'pdftohtml'), False)
|
||||||
|
|
||||||
|
@flush
|
||||||
def add_libjpeg(self):
|
def add_libjpeg(self):
|
||||||
print '\nAdding libjpeg'
|
print '\nAdding libjpeg'
|
||||||
self.install_dylib(os.path.join(SW, 'lib', 'libjpeg.7.dylib'))
|
self.install_dylib(os.path.join(SW, 'lib', 'libjpeg.7.dylib'))
|
||||||
|
|
||||||
|
@flush
|
||||||
def add_libpng(self):
|
def add_libpng(self):
|
||||||
print '\nAdding libpng'
|
print '\nAdding libpng'
|
||||||
self.install_dylib(os.path.join(SW, 'lib', 'libpng12.0.dylib'))
|
self.install_dylib(os.path.join(SW, 'lib', 'libpng12.0.dylib'))
|
||||||
|
|
||||||
|
@flush
|
||||||
def add_fontconfig(self):
|
def add_fontconfig(self):
|
||||||
print '\nAdding fontconfig'
|
print '\nAdding fontconfig'
|
||||||
for x in ('fontconfig.1', 'freetype.6', 'expat.1'):
|
for x in ('fontconfig.1', 'freetype.6', 'expat.1'):
|
||||||
@ -297,6 +353,7 @@ class Py2App(object):
|
|||||||
''')
|
''')
|
||||||
open(fc, 'wb').write(raw)
|
open(fc, 'wb').write(raw)
|
||||||
|
|
||||||
|
@flush
|
||||||
def add_imagemagick(self):
|
def add_imagemagick(self):
|
||||||
print '\nAdding ImageMagick'
|
print '\nAdding ImageMagick'
|
||||||
for x in ('Wand', 'Core'):
|
for x in ('Wand', 'Core'):
|
||||||
@ -315,11 +372,15 @@ class Py2App(object):
|
|||||||
f = join(x[0], f)
|
f = join(x[0], f)
|
||||||
self.fix_dependencies_in_lib(f)
|
self.fix_dependencies_in_lib(f)
|
||||||
|
|
||||||
|
@flush
|
||||||
def add_misc_libraries(self):
|
def add_misc_libraries(self):
|
||||||
for x in ('usb', 'unrar'):
|
for x in ('usb', 'unrar'):
|
||||||
print '\nAdding', x
|
print '\nAdding', x
|
||||||
shutil.copy2(join(SW, 'lib', 'lib%s.dylib'%x), self.frameworks_dir)
|
x = 'lib%s.dylib'%x
|
||||||
|
shutil.copy2(join(SW, 'lib', x), self.frameworks_dir)
|
||||||
|
self.set_id(join(self.frameworks_dir, x), self.FID+'/'+x)
|
||||||
|
|
||||||
|
@flush
|
||||||
def add_site_packages(self):
|
def add_site_packages(self):
|
||||||
print '\nAdding site-packages'
|
print '\nAdding site-packages'
|
||||||
self.site_packages = join(self.resources_dir, 'Python', 'site-packages')
|
self.site_packages = join(self.resources_dir, 'Python', 'site-packages')
|
||||||
@ -327,18 +388,19 @@ class Py2App(object):
|
|||||||
paths = reversed(map(abspath, [x for x in sys.path if x.startswith('/')]))
|
paths = reversed(map(abspath, [x for x in sys.path if x.startswith('/')]))
|
||||||
upaths = []
|
upaths = []
|
||||||
for x in paths:
|
for x in paths:
|
||||||
if x not in upaths:
|
|
||||||
upaths.append(x)
|
|
||||||
for x in upaths:
|
|
||||||
if x.endswith('/PIL') or 'site-packages' not in x:
|
if x.endswith('/PIL') or 'site-packages' not in x:
|
||||||
continue
|
continue
|
||||||
|
if x not in upaths:
|
||||||
|
upaths.append(x)
|
||||||
|
upaths.append(os.path.expanduser('~/build/calibre/src'))
|
||||||
|
for x in upaths:
|
||||||
tdir = None
|
tdir = None
|
||||||
try:
|
try:
|
||||||
if not os.path.isdir(x):
|
if not os.path.isdir(x):
|
||||||
try:
|
try:
|
||||||
zf = zipfile.ZipFile(x)
|
zf = zipfile.ZipFile(x)
|
||||||
except:
|
except:
|
||||||
print "WARNING:", x, 'is neither a directory nor a zipfile'
|
self.warn(x, 'is neither a directory nor a zipfile')
|
||||||
continue
|
continue
|
||||||
tdir = tempfile.mkdtemp()
|
tdir = tempfile.mkdtemp()
|
||||||
zf.extractall(tdir)
|
zf.extractall(tdir)
|
||||||
@ -350,6 +412,7 @@ class Py2App(object):
|
|||||||
shutil.rmtree(tdir)
|
shutil.rmtree(tdir)
|
||||||
self.remove_bytecode(join(self.resources_dir, 'Python', 'site-packages'))
|
self.remove_bytecode(join(self.resources_dir, 'Python', 'site-packages'))
|
||||||
|
|
||||||
|
@flush
|
||||||
def add_modules_from_dir(self, src):
|
def add_modules_from_dir(self, src):
|
||||||
for x in glob.glob(join(src, '*.py'))+glob.glob(join(src, '*.so')):
|
for x in glob.glob(join(src, '*.py'))+glob.glob(join(src, '*.so')):
|
||||||
dest = join(self.site_packages, basename(x))
|
dest = join(self.site_packages, basename(x))
|
||||||
@ -357,6 +420,7 @@ class Py2App(object):
|
|||||||
if x.endswith('.so'):
|
if x.endswith('.so'):
|
||||||
self.fix_dependencies_in_lib(x)
|
self.fix_dependencies_in_lib(x)
|
||||||
|
|
||||||
|
@flush
|
||||||
def add_packages_from_dir(self, src):
|
def add_packages_from_dir(self, src):
|
||||||
for x in os.listdir(src):
|
for x in os.listdir(src):
|
||||||
x = join(src, x)
|
x = join(src, x)
|
||||||
@ -365,46 +429,60 @@ class Py2App(object):
|
|||||||
continue
|
continue
|
||||||
self.add_package_dir(x)
|
self.add_package_dir(x)
|
||||||
|
|
||||||
|
@flush
|
||||||
def add_package_dir(self, x, dest=None):
|
def add_package_dir(self, x, dest=None):
|
||||||
def ignore(root, files):
|
def ignore(root, files):
|
||||||
ans = []
|
ans = []
|
||||||
for y in files:
|
for y in files:
|
||||||
if os.path.splitext(y) in ('.py', '.so'):
|
ext = os.path.splitext(y)[1]
|
||||||
continue
|
if ext not in ('', '.py', '.so') or \
|
||||||
ans.append(y)
|
(not ext and not os.path.isdir(join(root, y))):
|
||||||
|
ans.append(y)
|
||||||
|
|
||||||
return ans
|
return ans
|
||||||
if dest is None:
|
if dest is None:
|
||||||
dest = self.site_packages
|
dest = self.site_packages
|
||||||
dest = join(dest, basename(x))
|
dest = join(dest, basename(x))
|
||||||
shutil.copytree(x, dest, symlinks=True, ignore=ignore)
|
shutil.copytree(x, dest, symlinks=True, ignore=ignore)
|
||||||
self.postprocess_package(x, dest)
|
self.postprocess_package(x, dest)
|
||||||
|
for x in os.walk(dest):
|
||||||
|
for f in x[-1]:
|
||||||
|
if f.endswith('.so'):
|
||||||
|
f = join(x[0], f)
|
||||||
|
self.fix_dependencies_in_lib(f)
|
||||||
|
|
||||||
|
@flush
|
||||||
def filter_package(self, name):
|
def filter_package(self, name):
|
||||||
return name in ('Cython', 'modulegraph', 'macholib', 'py2app',
|
return name in ('Cython', 'modulegraph', 'macholib', 'py2app',
|
||||||
'bdist_mpkg', 'altgraph')
|
'bdist_mpkg', 'altgraph')
|
||||||
|
|
||||||
|
@flush
|
||||||
def postprocess_package(self, src_path, dest_path):
|
def postprocess_package(self, src_path, dest_path):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@flush
|
||||||
def add_stdlib(self):
|
def add_stdlib(self):
|
||||||
print '\nAdding python stdlib'
|
print '\nAdding python stdlib'
|
||||||
src = join(SW, 'python/Python.framework/Versions/Current/lib/python')
|
src = join(SW, 'python/Python.framework/Versions/Current/lib/python')
|
||||||
src += '.'.join(map(str, sys.version_info[:2]))
|
src += self.version_info
|
||||||
dest = join(self.resources_dir, 'Python', 'lib', 'python')
|
dest = join(self.resources_dir, 'Python', 'lib', 'python')
|
||||||
dest += '.'.join(map(str, sys.version_info[:2]))
|
dest += self.version_info
|
||||||
|
os.makedirs(dest)
|
||||||
for x in os.listdir(src):
|
for x in os.listdir(src):
|
||||||
if x in ('site-packages', 'config', 'test', 'lib2to3', 'lib-tk',
|
if x in ('site-packages', 'config', 'test', 'lib2to3', 'lib-tk',
|
||||||
'lib-old', 'idlelib', 'plat-mac', 'plat-darwin', 'site.py'):
|
'lib-old', 'idlelib', 'plat-mac', 'plat-darwin', 'site.py'):
|
||||||
continue
|
continue
|
||||||
|
x = join(src, x)
|
||||||
if os.path.isdir(x):
|
if os.path.isdir(x):
|
||||||
self.add_package_dir(join(src, x), dest)
|
self.add_package_dir(x, dest)
|
||||||
elif os.path.splitext(x) in ('.so', '.py'):
|
elif os.path.splitext(x)[1] in ('.so', '.py'):
|
||||||
shutil.copy2(join(src, x), dest)
|
shutil.copy2(x, dest)
|
||||||
dest = join(dest, basename(x))
|
dest2 = join(dest, basename(x))
|
||||||
if dest.endswith('.so'):
|
if dest2.endswith('.so'):
|
||||||
self.fix_dependencies_in_lib(dest)
|
self.fix_dependencies_in_lib(dest2)
|
||||||
self.remove_bytecode(join(self.resources_dir, 'Python', 'lib'))
|
self.remove_bytecode(join(self.resources_dir, 'Python', 'lib'))
|
||||||
|
|
||||||
|
@flush
|
||||||
def remove_bytecode(self, dest):
|
def remove_bytecode(self, dest):
|
||||||
for x in os.walk(dest):
|
for x in os.walk(dest):
|
||||||
root = x[0]
|
root = x[0]
|
||||||
@ -412,6 +490,7 @@ class Py2App(object):
|
|||||||
if os.path.splitext(f) in ('.pyc', '.pyo'):
|
if os.path.splitext(f) in ('.pyc', '.pyo'):
|
||||||
os.remove(join(root, f))
|
os.remove(join(root, f))
|
||||||
|
|
||||||
|
@flush
|
||||||
def compile_py_modules(self):
|
def compile_py_modules(self):
|
||||||
print '\nCompiling Python modules'
|
print '\nCompiling Python modules'
|
||||||
base = join(self.resources_dir, 'Python')
|
base = join(self.resources_dir, 'Python')
|
||||||
@ -425,8 +504,9 @@ class Py2App(object):
|
|||||||
py_compile.compile(y, dfile=rel, doraise=True)
|
py_compile.compile(y, dfile=rel, doraise=True)
|
||||||
os.remove(y)
|
os.remove(y)
|
||||||
except:
|
except:
|
||||||
print 'WARNING: Failed to byte-compile', y
|
self.warn('WARNING: Failed to byte-compile', y)
|
||||||
|
|
||||||
|
@flush
|
||||||
def create_console_app(self):
|
def create_console_app(self):
|
||||||
print '\nCreating console.app'
|
print '\nCreating console.app'
|
||||||
cc_dir = os.path.join(self.contents_dir, 'console.app', 'Contents')
|
cc_dir = os.path.join(self.contents_dir, 'console.app', 'Contents')
|
||||||
@ -442,16 +522,22 @@ class Py2App(object):
|
|||||||
os.symlink(join('../..', x),
|
os.symlink(join('../..', x),
|
||||||
join(cc_dir, x))
|
join(cc_dir, x))
|
||||||
|
|
||||||
|
@flush
|
||||||
def copy_launcher_and_site(self):
|
def copy_launcher_and_site(self):
|
||||||
base = os.path.dirname(__file__)
|
base = os.path.dirname(__file__)
|
||||||
for x in ('launcher', 'site'):
|
shutil.copy2(join(base, 'launcher.py'), self.resources_dir)
|
||||||
shutil.copy2(join(base, x+'.py'), self.resources_dir)
|
shutil.copy2(join(base, 'site.py'), join(self.resources_dir, 'Python',
|
||||||
|
'lib', 'python'+self.version_info))
|
||||||
|
|
||||||
|
|
||||||
|
@flush
|
||||||
def makedmg(self, d, volname,
|
def makedmg(self, d, volname,
|
||||||
destdir='dist',
|
destdir='dist',
|
||||||
internet_enable=True,
|
internet_enable=True,
|
||||||
format='UDBZ'):
|
format='UDBZ'):
|
||||||
''' Copy a directory d into a dmg named volname '''
|
''' Copy a directory d into a dmg named volname '''
|
||||||
|
print '\nCreating dmg'
|
||||||
|
sys.stdout.flush()
|
||||||
if not os.path.exists(destdir):
|
if not os.path.exists(destdir):
|
||||||
os.makedirs(destdir)
|
os.makedirs(destdir)
|
||||||
dmg = os.path.join(destdir, volname+'.dmg')
|
dmg = os.path.join(destdir, volname+'.dmg')
|
||||||
@ -461,6 +547,8 @@ class Py2App(object):
|
|||||||
'-volname', volname, '-format', format, dmg])
|
'-volname', volname, '-format', format, dmg])
|
||||||
if internet_enable:
|
if internet_enable:
|
||||||
subprocess.check_call(['/usr/bin/hdiutil', 'internet-enable', '-yes', dmg])
|
subprocess.check_call(['/usr/bin/hdiutil', 'internet-enable', '-yes', dmg])
|
||||||
|
size = os.stat(dmg).st_size/(1024*1024.)
|
||||||
|
print '\nInstaller size: %.2fMB\n'%size
|
||||||
return dmg
|
return dmg
|
||||||
|
|
||||||
|
|
||||||
|
@ -305,22 +305,25 @@ Device._fields_ = [ \
|
|||||||
]
|
]
|
||||||
|
|
||||||
if _libusb is not None:
|
if _libusb is not None:
|
||||||
_libusb.usb_get_busses.restype = POINTER(Bus)
|
try:
|
||||||
_libusb.usb_open.restype = POINTER(DeviceHandle)
|
_libusb.usb_get_busses.restype = POINTER(Bus)
|
||||||
_libusb.usb_open.argtypes = [POINTER(Device)]
|
_libusb.usb_open.restype = POINTER(DeviceHandle)
|
||||||
_libusb.usb_close.argtypes = [POINTER(DeviceHandle)]
|
_libusb.usb_open.argtypes = [POINTER(Device)]
|
||||||
_libusb.usb_claim_interface.argtypes = [POINTER(DeviceHandle), c_int]
|
_libusb.usb_close.argtypes = [POINTER(DeviceHandle)]
|
||||||
_libusb.usb_claim_interface.restype = c_int
|
_libusb.usb_claim_interface.argtypes = [POINTER(DeviceHandle), c_int]
|
||||||
_libusb.usb_release_interface.argtypes = [POINTER(DeviceHandle), c_int]
|
_libusb.usb_claim_interface.restype = c_int
|
||||||
_libusb.usb_release_interface.restype = c_int
|
_libusb.usb_release_interface.argtypes = [POINTER(DeviceHandle), c_int]
|
||||||
_libusb.usb_reset.argtypes = [POINTER(DeviceHandle)]
|
_libusb.usb_release_interface.restype = c_int
|
||||||
_libusb.usb_reset.restype = c_int
|
_libusb.usb_reset.argtypes = [POINTER(DeviceHandle)]
|
||||||
_libusb.usb_control_msg.restype = c_int
|
_libusb.usb_reset.restype = c_int
|
||||||
_libusb.usb_bulk_read.restype = c_int
|
_libusb.usb_control_msg.restype = c_int
|
||||||
_libusb.usb_bulk_write.restype = c_int
|
_libusb.usb_bulk_read.restype = c_int
|
||||||
_libusb.usb_set_configuration.argtypes = [POINTER(DeviceHandle), c_int]
|
_libusb.usb_bulk_write.restype = c_int
|
||||||
_libusb.usb_set_configuration.restype = c_int
|
_libusb.usb_set_configuration.argtypes = [POINTER(DeviceHandle), c_int]
|
||||||
_libusb.usb_init()
|
_libusb.usb_set_configuration.restype = c_int
|
||||||
|
_libusb.usb_init()
|
||||||
|
except:
|
||||||
|
_libusb = None
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -339,7 +339,7 @@ def main():
|
|||||||
dev.touch(args[0])
|
dev.touch(args[0])
|
||||||
else:
|
else:
|
||||||
parser.print_help()
|
parser.print_help()
|
||||||
if dev.handle: dev.close()
|
if getattr(dev, 'handle', False): dev.close()
|
||||||
return 1
|
return 1
|
||||||
except DeviceLocked:
|
except DeviceLocked:
|
||||||
print >> sys.stderr, "The device is locked. Use the --unlock option"
|
print >> sys.stderr, "The device is locked. Use the --unlock option"
|
||||||
|
@ -141,8 +141,9 @@ class MOBIOutput(OutputFormatPlugin):
|
|||||||
toc.nodes[0].href = toc.nodes[0].nodes[0].href
|
toc.nodes[0].href = toc.nodes[0].nodes[0].href
|
||||||
|
|
||||||
# GR diagnostics
|
# GR diagnostics
|
||||||
#self.dump_toc(toc)
|
if self.opts.verbose > 3:
|
||||||
#self.dump_manifest()
|
self.dump_toc(toc)
|
||||||
|
self.dump_manifest()
|
||||||
|
|
||||||
|
|
||||||
def convert(self, oeb, output_path, input_plugin, opts, log):
|
def convert(self, oeb, output_path, input_plugin, opts, log):
|
||||||
|
@ -52,7 +52,7 @@ class TXTMLizer(object):
|
|||||||
stylizer = Stylizer(item.data, item.href, self.oeb_book, self.opts.output_profile)
|
stylizer = Stylizer(item.data, item.href, self.oeb_book, self.opts.output_profile)
|
||||||
content = unicode(etree.tostring(item.data.find(XHTML('body')), encoding=unicode))
|
content = unicode(etree.tostring(item.data.find(XHTML('body')), encoding=unicode))
|
||||||
content = self.remove_newlines(content)
|
content = self.remove_newlines(content)
|
||||||
output.append(self.get_text(etree.fromstring(content), stylizer))
|
output += self.dump_text(etree.fromstring(content), stylizer))
|
||||||
output = self.cleanup_text(u''.join(output))
|
output = self.cleanup_text(u''.join(output))
|
||||||
|
|
||||||
return output
|
return output
|
||||||
@ -107,17 +107,6 @@ class TXTMLizer(object):
|
|||||||
|
|
||||||
return text
|
return text
|
||||||
|
|
||||||
def get_text(self, elem, stylizer):
|
|
||||||
'''
|
|
||||||
@elem: The element in the etree that we are working on.
|
|
||||||
@stylizer: The style information attached to the element.
|
|
||||||
@end: The last two characters of the text from the previous element.
|
|
||||||
This is used to determine if a blank line is needed when starting
|
|
||||||
a new block element.
|
|
||||||
'''
|
|
||||||
|
|
||||||
return u''.join(self.dump_text(elem, stylizer))
|
|
||||||
|
|
||||||
def dump_text(self, elem, stylizer, end=''):
|
def dump_text(self, elem, stylizer, end=''):
|
||||||
'''
|
'''
|
||||||
@elem: The element in the etree that we are working on.
|
@elem: The element in the etree that we are working on.
|
||||||
@ -147,7 +136,7 @@ class TXTMLizer(object):
|
|||||||
if not end.endswith(u'\n\n') and hasattr(elem, 'text') and elem.text != None and elem.text.strip() != '':
|
if not end.endswith(u'\n\n') and hasattr(elem, 'text') and elem.text != None and elem.text.strip() != '':
|
||||||
text.append(u'\n\n')
|
text.append(u'\n\n')
|
||||||
|
|
||||||
# Proccess tags that contain text.
|
# Process tags that contain text.
|
||||||
if hasattr(elem, 'text') and elem.text != None and elem.text.strip() != '':
|
if hasattr(elem, 'text') and elem.text != None and elem.text.strip() != '':
|
||||||
text.append(elem.text)
|
text.append(elem.text)
|
||||||
|
|
||||||
|
@ -17,7 +17,8 @@ class PluginWidget(Widget, Ui_Form):
|
|||||||
HELP = _('Options specific to')+' TXT '+_('output')
|
HELP = _('Options specific to')+' TXT '+_('output')
|
||||||
|
|
||||||
def __init__(self, parent, get_option, get_help, db=None, book_id=None):
|
def __init__(self, parent, get_option, get_help, db=None, book_id=None):
|
||||||
Widget.__init__(self, parent, 'txt_output', ['newline', 'inline_toc'])
|
Widget.__init__(self, parent, 'txt_output', ['newline', 'inline_toc',
|
||||||
|
'flush_paras', 'indent_paras'])
|
||||||
self.db, self.book_id = db, book_id
|
self.db, self.book_id = db, book_id
|
||||||
self.initialize_options(get_option, get_help, db, book_id)
|
self.initialize_options(get_option, get_help, db, book_id)
|
||||||
|
|
||||||
|
@ -922,6 +922,8 @@ class BasicNewsRecipe(Recipe):
|
|||||||
desc = a.text_summary
|
desc = a.text_summary
|
||||||
if not desc:
|
if not desc:
|
||||||
desc = None
|
desc = None
|
||||||
|
else:
|
||||||
|
desc = self.description_limiter(desc)
|
||||||
entries.append('%sindex.html'%adir)
|
entries.append('%sindex.html'%adir)
|
||||||
po = self.play_order_map.get(entries[-1], None)
|
po = self.play_order_map.get(entries[-1], None)
|
||||||
if po is None:
|
if po is None:
|
||||||
|
@ -12,46 +12,68 @@ from calibre.web.feeds.news import BasicNewsRecipe
|
|||||||
class BusinessWeek(BasicNewsRecipe):
|
class BusinessWeek(BasicNewsRecipe):
|
||||||
title = 'Business Week'
|
title = 'Business Week'
|
||||||
description = 'Business News, Stock Market and Financial Advice'
|
description = 'Business News, Stock Market and Financial Advice'
|
||||||
__author__ = 'ChuckEggDotCom'
|
__author__ = 'ChuckEggDotCom and Sujata Raman'
|
||||||
language = _('English')
|
language = _('English')
|
||||||
oldest_article = 7
|
oldest_article = 7
|
||||||
max_articles_per_feed = 10
|
max_articles_per_feed = 10
|
||||||
|
no_stylesheets = True
|
||||||
|
|
||||||
remove_tags_before = dict(name='h1')
|
|
||||||
remove_tags_after = dict(id='footer')
|
extra_css = '''
|
||||||
remove_tags = [dict(attrs={'class':['articleTools', 'post-tools', 'side_tool']}),
|
h1{font-family :Arial,Helvetica,sans-serif; font-size:large;}
|
||||||
dict(id=['footer', 'navigation', 'archive', 'side_search', 'blog_sidebar', 'side_tool', 'side_index']),
|
h2{font-family :Arial,Helvetica,sans-serif; font-size:small;color:#666666;}
|
||||||
dict(name='h2', attrs={'class':'listspace'}),
|
p{font-family :Arial,Helvetica,sans-serif; }
|
||||||
]
|
#lede600{font-size:x-small;}
|
||||||
|
#storybody{font-size:x-small;}
|
||||||
|
.strap{font-family :Arial,Helvetica,sans-serif; font-size:x-small; color:#064599;}
|
||||||
|
.byline{font-family :Arial,Helvetica,sans-serif; font-size:x-small;}
|
||||||
|
.postedBy{font-family :Arial,Helvetica,sans-serif; font-size:x-small;color:#666666;}
|
||||||
|
.trackback{font-family :Arial,Helvetica,sans-serif; font-size:x-small;color:#666666;}
|
||||||
|
.date{font-family :Arial,Helvetica,sans-serif; font-size:x-small;color:#666666;}
|
||||||
|
.wrapper{font-family :Arial,Helvetica,sans-serif; font-size:x-small;}
|
||||||
|
.photoCredit{font-family :Arial,Helvetica,sans-serif; font-size:x-small;color:#666666;}
|
||||||
|
.tagline{font-family :Arial,Helvetica,sans-serif; font-size:x-small;color:#666666;}
|
||||||
|
'''
|
||||||
|
|
||||||
|
remove_tags = [ dict(name='div', attrs={'id':["bw2-header","column2","wrapper-bw2-footer","wrapper-mgh-footer","inset","commentForm","commentDisplay","bwExtras","bw2-umbrella","readerComments","pageNav","leg"]}),
|
||||||
|
]
|
||||||
|
|
||||||
feeds = [
|
feeds = [
|
||||||
(u'Top Stories', u'http://www.businessweek.com/topStories/rss/topStories.rss'),
|
(u'Top Stories', u'http://www.businessweek.com/topStories/rss/topStories.rss'),
|
||||||
(u'Top News', u'http://www.businessweek.com/rss/bwdaily.rss'),
|
(u'Top News', u'http://www.businessweek.com/rss/bwdaily.rss'),
|
||||||
(u'Asia', u'http://www.businessweek.com/rss/asia.rss'),
|
(u'Asia', u'http://www.businessweek.com/rss/asia.rss'),
|
||||||
(u'Autos', u'http://www.businessweek.com/rss/autos/index.rss'),
|
(u'Autos', u'http://www.businessweek.com/rss/autos/index.rss'),
|
||||||
(u'Classic Cars', u'http://www.businessweek.com/rss/autos/classic_cars/index.rss'),
|
(u'Classic Cars', u'http://rss.businessweek.com/bw_rss/classiccars'),
|
||||||
(u'Hybrids', u'http://www.businessweek.com/rss/hybrids/index.rss'),
|
(u'Hybrids', u'http://rss.businessweek.com/bw_rss/hybrids'),
|
||||||
(u'Europe', u'http://www.businessweek.com/rss/europe.rss'),
|
(u'Europe', u'http://www.businessweek.com/rss/europe.rss'),
|
||||||
(u'Auto Reviews', u'http://www.businessweek.com/rss/autos/reviews/index.rss'),
|
(u'Auto Reviews', u'http://rss.businessweek.com/bw_rss/autoreviews'),
|
||||||
(u'Innovation & Design', u'http://www.businessweek.com/rss/innovate.rss'),
|
(u'Innovation & Design', u'http://www.businessweek.com/rss/innovate.rss'),
|
||||||
(u'Architecture', u'http://www.businessweek.com/rss/architecture.rss'),
|
(u'Architecture', u'http://www.businessweek.com/rss/architecture.rss'),
|
||||||
(u'Brand Equity', u'http://www.businessweek.com/rss/brandequity.rss'),
|
(u'Brand Equity', u'http://www.businessweek.com/rss/brandequity.rss'),
|
||||||
(u'Auto Design', u'http://www.businessweek.com/rss/carbuff.rss'),
|
(u'Auto Design', u'http://www.businessweek.com/rss/carbuff.rss'),
|
||||||
(u'Game Room', u'http://www.businessweek.com/rss/gameroom.rss'),
|
(u'Game Room', u'http://rss.businessweek.com/bw_rss/gameroom'),
|
||||||
(u'Technology', u'http://www.businessweek.com/rss/technology.rss'),
|
(u'Technology', u'http://www.businessweek.com/rss/technology.rss'),
|
||||||
(u'Investing', u'http://www.businessweek.m/rss/investor.rss'),
|
(u'Investing', u'http://rss.businessweek.com/bw_rss/investor'),
|
||||||
(u'Small Business', u'http://www.businessweek.com/rss/smallbiz.rss'),
|
(u'Small Business', u'http://www.businessweek.com/rss/smallbiz.rss'),
|
||||||
(u'Careers', u'http://www.businessweek.com/rss/careers.rss'),
|
(u'Careers', u'http://rss.businessweek.com/bw_rss/careers'),
|
||||||
(u'B-Schools', u'http://www.businessweek.com/rss/bschools.rss'),
|
(u'B-Schools', u'http://www.businessweek.com/rss/bschools.rss'),
|
||||||
(u'Magazine Selections', u'http://www.businessweek.com/rss/magazine.rss'),
|
(u'Magazine Selections', u'http://www.businessweek.com/rss/magazine.rss'),
|
||||||
(u'CEO Guide to Tech', u'http://www.businessweek.com/rss/ceo_guide_tech.rss'),
|
(u'CEO Guide to Tech', u'http://www.businessweek.com/rss/ceo_guide_tech.rss'),
|
||||||
]
|
]
|
||||||
|
|
||||||
def get_article_url(self, article):
|
def get_article_url(self, article):
|
||||||
|
|
||||||
url = article.get('guid', None)
|
url = article.get('guid', None)
|
||||||
if 'podcasts' in url:
|
|
||||||
|
if 'podcasts' in url or 'surveys' in url:
|
||||||
url = None
|
url = None
|
||||||
|
|
||||||
return url
|
return url
|
||||||
|
|
||||||
def print_version(self, url):
|
def postrocess_html(self, soup, first):
|
||||||
return url.replace('http://www.businessweek.com/', 'http://www.businessweek.com/print/')
|
|
||||||
|
for tag in soup.findAll(name=['ul','li']):
|
||||||
|
tag.name = 'div'
|
||||||
|
|
||||||
|
return soup
|
||||||
|
|
||||||
|
@ -523,8 +523,9 @@ class VMInstaller(OptionlessCommand):
|
|||||||
--exclude "*.pyc" --exclude "*.pyo" --exclude "*.swp" --exclude "*.swo" \
|
--exclude "*.pyc" --exclude "*.pyo" --exclude "*.swp" --exclude "*.swo" \
|
||||||
rsync://%(host)s/work/%(project)s . && \
|
rsync://%(host)s/work/%(project)s . && \
|
||||||
cd %(project)s && \
|
cd %(project)s && \
|
||||||
|
rm -rf src/calibre/plugins/* && \
|
||||||
%%s && \
|
%%s && \
|
||||||
rm -rf build/* dist/* src/calibre/plugins/* && \
|
rm -rf build/* dist/* && \
|
||||||
%%s %%s
|
%%s %%s
|
||||||
'''%dict(host=HOST, project=__appname__))
|
'''%dict(host=HOST, project=__appname__))
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user