~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to tools/prepare_for_latex.py

  • Committer: Colin D Bennett
  • Date: 2009-02-12 17:21:02 UTC
  • mto: This revision was merged to the branch mainline in revision 4008.
  • Revision ID: colin@gibibit.com-20090212172102-0t7xufywds9l1g33
Strip trailing whitespace.

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
# Modify reStructuredText 'image' directives by adding a percentage 'width'
4
4
# attribute so that the images are scaled to fit on the page when the document
5
5
# is renderd to LaTeX, and add a center alignment.
6
 
 
6
#
7
7
# Also convert references to PNG images to use PDF files generated from SVG
8
8
# files if available.
9
9
#
72
72
            if directive_match is not None:
73
73
                image_src = directive_match.group(1)
74
74
                if verbose:
75
 
                    print('Image ' + image_src + ' in ' + filename 
 
75
                    print('Image ' + image_src + ' in ' + filename
76
76
                          + ': ' + line.strip())
77
77
 
78
78
                foundimg = True
93
93
 
94
94
    def replace_extension(self, path, newext):
95
95
        if path.endswith(newext):
96
 
            raise Exception("File '" + path + "' already has extension '" 
 
96
            raise Exception("File '" + path + "' already has extension '"
97
97
                            + newext +"'")
98
98
        dot = path.rfind('.')
99
99
        if dot == -1:
128
128
                         '--export-pdf=' + pdfpath, svgpath]) != 0:
129
129
                    raise Exception("Conversion to pdf failed")
130
130
                return pdffile
131
 
        
 
131
 
132
132
        # No conversion, just copy the file.
133
133
        srcpath = os.path.join(self.srcdir, filename)
134
134
        destpath = os.path.join(self.destdir, filename)
149
149
        print('while adjusting the use of images and possibly converting SVG')
150
150
        print('images to PDF files so LaTeX can include them.')
151
151
        sys.exit(1)
152
 
    
 
152
 
153
153
    for arg in argv[1:]:
154
154
        if arg == '-v' or arg == '--verbose':
155
155
            verbose = True