Embed client and server release numbers

Note that this also removes the changelog - I'm going to re-add the
changelog differently soon.
This commit is contained in:
Daniel Wagner-Hall 2015-12-01 17:02:23 +00:00
parent bcead3b0a5
commit 97fd1fdd62
6 changed files with 73 additions and 42 deletions

View file

@ -44,6 +44,7 @@ import importlib
import json
import logging
import os
import re
import sys
from textwrap import TextWrapper
@ -56,7 +57,7 @@ def check_unaccessed(name, store):
log("Found %s unused %s keys." % (len(unaccessed_keys), name))
log(unaccessed_keys)
def main(input_module, file_stream=None, out_dir=None, verbose=False):
def main(input_module, file_stream=None, out_dir=None, verbose=False, substitutions={}):
if out_dir and not os.path.exists(out_dir):
os.makedirs(out_dir)
@ -167,6 +168,12 @@ def main(input_module, file_stream=None, out_dir=None, verbose=False):
temp = Template(temp_str)
log("Creating output for: %s" % file_stream.name)
output = create_from_template(temp, sections)
# Do these substitutions outside of the ordinary templating system because
# we want them to apply to things like the underlying swagger used to
# generate the templates, not just the top-level sections.
for old, new in substitutions.items():
output = output.replace(old, new)
with open(
os.path.join(out_dir, os.path.basename(file_stream.name)), "w"
) as f:
@ -209,6 +216,10 @@ if __name__ == '__main__':
"--verbose", "-v", action="store_true",
help="Turn on verbose mode."
)
parser.add_argument(
"--substitution", action="append",
help="Substitutions to apply to the generated output, of form NEEDLE=REPLACEMENT."
)
args = parser.parse_args()
if args.verbose:
@ -226,7 +237,14 @@ if __name__ == '__main__':
parser.print_help()
sys.exit(1)
substitutions = {}
for substitution in args.substitution:
parts = substitution.split("=", 1)
if len(parts) != 2:
raise Exception("Invalid substitution")
substitutions[parts[0]] = parts[1]
main(
args.input, file_stream=args.file, out_dir=args.out_directory,
verbose=args.verbose
substitutions=substitutions, verbose=args.verbose
)