sd/milkymist-memcard: Fix format string
[qemu/armbru.git] / tests / docker / travis.py
blob37307ac3664de5af4b379ae80bd9185d9f60da86
1 #!/usr/bin/env python3
3 # Travis YAML config parser
5 # Copyright (c) 2016 Red Hat Inc.
7 # Authors:
8 # Fam Zheng <famz@redhat.com>
10 # This work is licensed under the terms of the GNU GPL, version 2
11 # or (at your option) any later version. See the COPYING file in
12 # the top-level directory.
14 import sys
15 import yaml
16 import itertools
18 def load_yaml(fname):
19 return yaml.safe_load(open(fname, "r").read())
21 def conf_iter(conf):
22 # If "compiler" is omitted from the included env then Travis picks the
23 # first entry of the global compiler list.
24 default_compiler = conf["compiler"][0]
25 def env_to_list(env):
26 return env if isinstance(env, list) else [env]
27 for entry in conf["matrix"]["include"]:
28 yield {"env": env_to_list(entry["env"]),
29 "compiler": entry.get("compiler", default_compiler)}
31 def main():
32 if len(sys.argv) < 2:
33 sys.stderr.write("Usage: %s <travis-file>\n" % sys.argv[0])
34 return 1
35 conf = load_yaml(sys.argv[1])
36 print("\n".join((": ${%s}" % var for var in conf["env"]["global"])))
37 for config in conf_iter(conf):
38 print("(")
39 print("\n".join(config["env"]))
40 print("alias cc=" + config["compiler"])
41 print("\n".join(conf["before_script"]))
42 print("\n".join(conf["script"]))
43 print(")")
44 return 0
46 if __name__ == "__main__":
47 sys.exit(main())