~ubuntu-branches/ubuntu/karmic/calibre/karmic

« back to all changes in this revision

Viewing changes to src/calibre/ebooks/mobi/from_comic.py

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2009-07-30 12:49:41 UTC
  • mfrom: (1.3.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20090730124941-qjdsmri25zt8zocn
Tags: 0.6.3+dfsg-0ubuntu1
* New upstream release. Please see http://calibre.kovidgoyal.net/new_in_6/
  for the list of new features and changes.
* remove_postinstall.patch: Update for new version.
* build_debug.patch: Does not apply any more, disable for now. Might not be
  necessary any more.
* debian/copyright: Fix reference to versionless GPL.
* debian/rules: Drop obsolete dh_desktop call.
* debian/rules: Add workaround for weird Python 2.6 setuptools behaviour of
  putting compiled .so files into src/calibre/plugins/calibre/plugins
  instead of src/calibre/plugins.
* debian/rules: Drop hal fdi moving, new upstream version does not use hal
  any more. Drop hal dependency, too.
* debian/rules: Install udev rules into /lib/udev/rules.d.
* Add debian/calibre.preinst: Remove unmodified
  /etc/udev/rules.d/95-calibre.rules on upgrade.
* debian/control: Bump Python dependencies to 2.6, since upstream needs
  it now.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/env  python
2
 
__license__   = 'GPL v3'
3
 
__copyright__ = '2009, Kovid Goyal kovid@kovidgoyal.net'
4
 
__docformat__ = 'restructuredtext en'
5
 
 
6
 
'''
7
 
'''
8
 
import sys, os
9
 
from calibre.ebooks.lrf.comic.convert_from import do_convert, option_parser, \
10
 
                        ProgressBar, terminal_controller
11
 
from calibre.ebooks.mobi.from_any import config, any2mobi
12
 
from calibre.ptempfile import PersistentTemporaryFile
13
 
 
14
 
 
15
 
def convert(path_to_file, opts, notification=lambda m, p: p):
16
 
    pt = PersistentTemporaryFile('_comic2mobi.epub')
17
 
    pt.close()
18
 
    orig_output = opts.output
19
 
    opts.output = pt.name
20
 
    do_convert(path_to_file, opts, notification=notification, output_format='epub')
21
 
    opts = config('').parse()
22
 
    if orig_output is None:
23
 
        orig_output = os.path.splitext(path_to_file)[0]+'.mobi'
24
 
    opts.output = orig_output
25
 
    any2mobi(opts, pt.name)
26
 
 
27
 
def main(args=sys.argv):
28
 
    parser = option_parser()
29
 
    opts, args = parser.parse_args(args)
30
 
    if len(args) < 2:
31
 
        parser.print_help()
32
 
        print '\nYou must specify a file to convert'
33
 
        return 1
34
 
    
35
 
    pb = ProgressBar(terminal_controller, _('Rendering comic pages...'), 
36
 
                     no_progress_bar=opts.no_progress_bar or getattr(opts, 'no_process', False))
37
 
    notification = pb.update
38
 
    
39
 
    source = os.path.abspath(args[1])
40
 
    convert(source, opts, notification=notification)
41
 
    return 0
42
 
 
43
 
if __name__ == '__main__':
44
 
    sys.exit(main())
 
 
b'\\ No newline at end of file'