From be09cd859d5a9819b997137435166e624257dd10 Mon Sep 17 00:00:00 2001 From: Richard van der Hoff Date: Wed, 4 May 2016 18:33:52 +0100 Subject: [PATCH] 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 --- templating/build.py | 9 +++++---- templating/matrix_templates/units.py | 6 +++--- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/templating/build.py b/templating/build.py index 5c74d467..4737a6b1 100755 --- a/templating/build.py +++ b/templating/build.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -""" +""" Batesian: A simple templating system using Jinja. 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 for input_filename in files: - output_filename = os.path.join(out_dir, + output_filename = os.path.join(out_dir, os.path.basename(input_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." ) parser.add_argument( - "--input", "-i", + "--input", "-i", help="The python module (not file) which contains the sections/units "+ "classes. This module must have an 'exports' dict which has "+ "{ 'units': UnitClass, 'sections': SectionClass, "+ @@ -230,7 +230,8 @@ if __name__ == '__main__': ) parser.add_argument( "--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() diff --git a/templating/matrix_templates/units.py b/templating/matrix_templates/units.py index e046c82a..2cd14509 100644 --- a/templating/matrix_templates/units.py +++ b/templating/matrix_templates/units.py @@ -544,15 +544,15 @@ class MatrixUnits(Units): return { "rows": [{ "key": "`Client-Server API `_", - "type": substitutions["%CLIENT_RELEASE_LABEL%"], + "type": substitutions.get("%CLIENT_RELEASE_LABEL%", "unstable"), "desc": "Interaction between clients and servers", }, { "key": "`Server-Server API `_", - "type": substitutions["%SERVER_RELEASE_LABEL%"], + "type": substitutions.get("%SERVER_RELEASE_LABEL%", "unstable"), "desc": "Federation between servers", }, { "key": "`Application Service API `_", - "type": substitutions["%CLIENT_RELEASE_LABEL%"], + "type": substitutions.get("%CLIENT_RELEASE_LABEL%", "unstable"), "desc": "Privileged server plugins", }, { "key": "`Identity Service API `_",