/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/rst2pdf.py

  • Committer: Jelmer Vernooij
  • Date: 2018-11-12 01:41:38 UTC
  • mto: (7143.16.20 even-more-cleanups)
  • mto: This revision was merged to the branch mainline in revision 7175.
  • Revision ID: jelmer@jelmer.uk-20181112014138-3b0zyx91cu3wdq3k
More PEP8 fixes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
10
10
A front end to the Docutils Publisher, producing PDF.
11
11
 
12
12
Produces a latex file with the "latex" writer and converts
13
 
it to PDF with the "rubber" building system for LaTeX documents. 
 
13
it to PDF with the "rubber" building system for LaTeX documents.
14
14
"""
15
15
 
16
16
# ``rst2pdf.py`` is a PDF front-end for docutils that is compatible
17
17
# with the ``rst2*.py`` front ends of the docutils_ suite.
18
18
# It enables the generation of PDF documents from a reStructuredText source in
19
19
# one step.
20
 
21
 
# It is implemented as a combination of docutils' ``rst2latex.py`` 
 
20
#
 
21
# It is implemented as a combination of docutils' ``rst2latex.py``
22
22
# by David Goodger and rubber_ by Emmanuel Beffara.
23
 
 
23
#
24
24
# Copyright: © 2008 Günter Milde
25
25
#            Licensed under the `Apache License, Version 2.0`_
26
26
#            Provided WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND
27
 
 
27
#
28
28
# Changelog
29
29
# ---------
30
 
 
30
#
31
31
# =====  ==========  =======================================================
32
32
# 0.1    2008-05-20  first attempt
33
33
# =====  ==========  =======================================================
34
 
35
 
# :: 
 
34
#
 
35
# ::
36
36
 
37
37
_version = 0.1
38
38
 
68
68
 
69
69
# Generate the latex file
70
70
# =======================
71
 
 
71
#
72
72
# We need to replace the <destination> by a intermediate latex file path.
73
 
# The most reliable way to get the value of <destination> is to 
74
 
# call the Publisher "by hand", and query its settings. 
75
 
 
73
# The most reliable way to get the value of <destination> is to
 
74
# call the Publisher "by hand", and query its settings.
 
75
#
76
76
# Modeled on the publish_cmdline() function of docutils.core
77
 
 
77
#
78
78
# Default values::
79
79
 
80
80
reader=None
104
104
pub = Publisher(reader, parser, writer, settings=settings)
105
105
pub.set_components(reader_name, parser_name, writer_name)
106
106
 
107
 
# Parse the command line args 
 
107
# Parse the command line args
108
108
# (Publisher.publish does this in a try statement)::
109
109
 
110
 
pub.process_command_line(argv, usage, description, settings_spec, 
 
110
pub.process_command_line(argv, usage, description, settings_spec,
111
111
                         config_section, **(settings_overrides or {}))
112
112
# pprint(pub.settings.__dict__)
113
113
 
119
119
 
120
120
# Generate names for the temporary files and set ``destination`` to temporary
121
121
# latex file:
122
 
 
122
#
123
123
# make_name() from rubber.cmd_pipe checks that no existing file is
124
124
# overwritten. If we are going to support rubbers ``--inplace`` and ``--into``
125
125
# options, the chdir() must occure before this point to have the check in the
133
133
 
134
134
# Now do the rst -> latex conversion::
135
135
 
136
 
pub.publish(argv, usage, description, settings_spec, settings_overrides, 
 
136
pub.publish(argv, usage, description, settings_spec, settings_overrides,
137
137
            config_section=config_section, enable_exit_status=enable_exit_status)
138
138
 
139
139
 
140
140
# Generating the PDF document with rubber
141
141
# =======================================
142
 
143
 
 
142
#
 
143
#
144
144
# rubber_ has no documentet API for programmatic use. We simualate a command
145
145
# line call and pass command line arguments (see man: rubber-pipe) in an array::
146
146
 
163
163
    os.rename(pdfpath, destination)
164
164
 
165
165
# Clean up (remove intermediate files)
166
 
 
166
#
167
167
# ::
168
168
 
169
169
tex_processor(["--clean"] + rubber_argv)
171
171
 
172
172
 
173
173
# .. References
174
 
 
174
#
175
175
# .. _docutils: http://docutils.sourceforge.net/
176
176
# .. _rubber: http://www.pps.jussieu.fr/~beffara/soft/rubber/
177
177
# .. _Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0
178
 
#                                                                         
 
178
#