Fix errors when running build.py with default args

Fixes ugly errors when build.py was run (a) with no --substitutions at all, and
(b) without the expected substitutions
This commit is contained in:
Richard van der Hoff 2016-05-04 18:33:52 +01:00
parent 432c78f3b5
commit be09cd859d
2 changed files with 8 additions and 7 deletions

View file

@ -1,5 +1,5 @@
#!/usr/bin/env python #!/usr/bin/env python
""" """
Batesian: A simple templating system using Jinja. Batesian: A simple templating system using Jinja.
Architecture Architecture
@ -156,7 +156,7 @@ def main(input_module, files=None, out_dir=None, verbose=False, substitutions={}
# check the input files and substitute in sections where required # check the input files and substitute in sections where required
for input_filename in files: for input_filename in files:
output_filename = os.path.join(out_dir, output_filename = os.path.join(out_dir,
os.path.basename(input_filename)) os.path.basename(input_filename))
process_file(env, sections, input_filename, output_filename) process_file(env, sections, input_filename, output_filename)
@ -208,7 +208,7 @@ if __name__ == '__main__':
"then output under the same name to the output directory." "then output under the same name to the output directory."
) )
parser.add_argument( parser.add_argument(
"--input", "-i", "--input", "-i",
help="The python module (not file) which contains the sections/units "+ help="The python module (not file) which contains the sections/units "+
"classes. This module must have an 'exports' dict which has "+ "classes. This module must have an 'exports' dict which has "+
"{ 'units': UnitClass, 'sections': SectionClass, "+ "{ 'units': UnitClass, 'sections': SectionClass, "+
@ -230,7 +230,8 @@ if __name__ == '__main__':
) )
parser.add_argument( parser.add_argument(
"--substitution", action="append", "--substitution", action="append",
help="Substitutions to apply to the generated output, of form NEEDLE=REPLACEMENT." help="Substitutions to apply to the generated output, of form NEEDLE=REPLACEMENT.",
default=[],
) )
args = parser.parse_args() args = parser.parse_args()

View file

@ -544,15 +544,15 @@ class MatrixUnits(Units):
return { return {
"rows": [{ "rows": [{
"key": "`Client-Server API <client_server.html>`_", "key": "`Client-Server API <client_server.html>`_",
"type": substitutions["%CLIENT_RELEASE_LABEL%"], "type": substitutions.get("%CLIENT_RELEASE_LABEL%", "unstable"),
"desc": "Interaction between clients and servers", "desc": "Interaction between clients and servers",
}, { }, {
"key": "`Server-Server API <server_server.html>`_", "key": "`Server-Server API <server_server.html>`_",
"type": substitutions["%SERVER_RELEASE_LABEL%"], "type": substitutions.get("%SERVER_RELEASE_LABEL%", "unstable"),
"desc": "Federation between servers", "desc": "Federation between servers",
}, { }, {
"key": "`Application Service API <application_service.html>`_", "key": "`Application Service API <application_service.html>`_",
"type": substitutions["%CLIENT_RELEASE_LABEL%"], "type": substitutions.get("%CLIENT_RELEASE_LABEL%", "unstable"),
"desc": "Privileged server plugins", "desc": "Privileged server plugins",
}, { }, {
"key": "`Identity Service API <identity_service.html>`_", "key": "`Identity Service API <identity_service.html>`_",