/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to tools/prepare_for_latex.py

  • Committer: Breezy landing bot
  • Author(s): Colin Watson
  • Date: 2020-11-16 21:47:08 UTC
  • mfrom: (7521.1.1 remove-lp-workaround)
  • Revision ID: breezy.the.bot@gmail.com-20201116214708-jos209mgxi41oy15
Remove breezy.git workaround for bazaar.launchpad.net.

Merged from https://code.launchpad.net/~cjwatson/brz/remove-lp-workaround/+merge/393710

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/python
 
1
#!/usr/bin/python3
2
2
#
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
35
35
 
36
36
verbose = False
37
37
 
38
 
IMAGE_DIRECTIVE_PATTERN = re.compile(ur'^..\s+image::\s+(.*)\s+$')
39
 
DIRECTIVE_ELEMENT_PATTERN = re.compile(ur'^\s+:[^:]+:\s+')
 
38
IMAGE_DIRECTIVE_PATTERN = re.compile(u'^..\\s+image::\\s+(.*)\\`\\s+$')
 
39
DIRECTIVE_ELEMENT_PATTERN = re.compile(u'^\\s+:[^:]+:\\s+')
40
40
 
41
41
class Converter(object):
42
42
    def __init__(self, srcdir, destdir):
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
76
 
                          + ': ' + line.strip())
 
75
                    print(('Image ' + image_src + ' in ' + filename
 
76
                          + ': ' + line.strip()))
77
77
 
78
78
                foundimg = True
79
79
            outfile.write(line)
94
94
    def replace_extension(self, path, newext):
95
95
        if path.endswith(newext):
96
96
            raise Exception("File '" + path + "' already has extension '"
97
 
                            + newext +"'")
 
97
                            + newext + "'")
98
98
        dot = path.rfind('.')
99
99
        if dot == -1:
100
100
            return path + newext
142
142
    destdir = None
143
143
 
144
144
    if len(argv) < 2:
145
 
        print('Usage: ' + argv[0] + ' ' + IN_DIR_OPT + 'INDIR '
146
 
              + OUT_DIR_OPT + 'OUTDIR')
147
 
        print
 
145
        print(('Usage: ' + argv[0] + ' ' + IN_DIR_OPT + 'INDIR '
 
146
              + OUT_DIR_OPT + 'OUTDIR'))
 
147
        print()
148
148
        print('This will convert all .txt files in INDIR into file in OUTDIR')
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.')
158
158
        elif arg.startswith(OUT_DIR_OPT):
159
159
            destdir = arg[len(OUT_DIR_OPT):]
160
160
        else:
161
 
            print('Invalid argument ' + arg)
 
161
            print(('Invalid argument ' + arg))
162
162
            sys.exit(1)
163
163
 
164
164
    if srcdir is None or destdir is None:
165
 
        print('Please specify the ' + IN_DIR_OPT + ' and '
166
 
              + OUT_DIR_OPT + ' options.')
 
165
        print(('Please specify the ' + IN_DIR_OPT + ' and '
 
166
              + OUT_DIR_OPT + ' options.'))
167
167
        sys.exit(1)
168
168
 
169
169
    if not os.path.exists(destdir):