~mgedmin/+junk/pdf2html

« back to all changes in this revision

Viewing changes to pdf2html.py

  • Committer: Marius Gedminas
  • Date: 2010-05-12 16:48:10 UTC
  • Revision ID: marius@gedmin.as-20100512164810-mhxejdi0mmb1092a
Add --keep.

Show diffs side-by-side

added added

removed removed

Lines of Context:
61
61
from xml.etree import cElementTree as ET
62
62
 
63
63
 
64
 
__version__ = '0.3'
 
64
__version__ = '0.4'
65
65
__author__ = 'Marius Gedminas'
66
66
 
67
67
 
74
74
 
75
75
    _defs = [
76
76
        ('debug', bool),
 
77
        ('keep', bool),
77
78
        ('title', str),
78
79
        ('subtitle', str),
79
80
        ('header_pos', int),
84
85
 
85
86
    _help = dict(
86
87
        debug='print verbose diagnostics',
 
88
        keep='keep temporary files',
87
89
        header_pos='suppress text above this point (header)',
88
90
        footer_pos='suppress text below this point (footer)',
89
91
        title='document title',
142
144
        xml_file += '.xml'
143
145
        convert_pdfxml_to_html(xml_file, html_file, opts)
144
146
    finally:
145
 
        shutil.rmtree(tmpdir)
 
147
        if opts and opts.keep:
 
148
            print "Temporary files kept in %s" % tmpdir
 
149
        else:
 
150
            shutil.rmtree(tmpdir)
146
151
 
147
152
 
148
153
def convert_pdfxml_to_html(xml_file, html_file, opts=None):