qapi: drop the sentinel in enum array
[qemu/armbru.git] / tests / docker / travis.py
blob703a7fde85258a73efd1aed2710199de43c510c1
1 #!/usr/bin/env python
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.load(open(fname, "r").read())
21 def conf_iter(conf):
22 def env_to_list(env):
23 return env if isinstance(env, list) else [env]
24 for entry in conf["matrix"]["include"]:
25 yield {"env": env_to_list(entry["env"]),
26 "compiler": entry["compiler"]}
27 for entry in itertools.product(conf["compiler"],
28 conf["env"]["matrix"]):
29 yield {"env": env_to_list(entry[1]),
30 "compiler": entry[0]}
32 def main():
33 if len(sys.argv) < 2:
34 sys.stderr.write("Usage: %s <travis-file>\n" % sys.argv[0])
35 return 1
36 conf = load_yaml(sys.argv[1])
37 print "\n".join((": ${%s}" % var for var in conf["env"]["global"]))
38 for config in conf_iter(conf):
39 print "("
40 print "\n".join(config["env"])
41 print "alias cc=" + config["compiler"]
42 print "\n".join(conf["before_script"])
43 print "\n".join(conf["script"])
44 print ")"
45 return 0
47 if __name__ == "__main__":
48 sys.exit(main())