interop/organize.py
Mark T. Voelker c8138d4fa5 Add pep8/flake8 checks, fix flake8 errors
We're starting to accumulate a number of python scripts in
various parts of the tree, and probably will continue to do so.
To make maintenance easier over time, we should have basic
pep8/flake8 checks in place for python code, as is best practice
elsewhere in the OpenStack project.  This patch adds basic checks
and corrects existing errors in our python scripts so that going
forward we can opt to gate on clean python code.

Change-Id: Ie32ee7a14ee608e12f42288e137a0849555b5ed8
2015-08-18 12:18:01 +00:00

61 lines
2.0 KiB
Python

import json
defcore = json.loads(open('2015.next.json', 'r').read())
new_caps = json.loads(open('newcaps.json', 'r').read())
capabilities = {}
old_capabilities = defcore["capabilities"]
for old_capability in old_capabilities:
old_capability = old_capabilities[old_capability]
achievements = old_capability["achievements"]
admin = old_capability["admin"]
try:
required_since = old_capability["required-since"]
except:
required_since = ""
description = old_capability["description"]
name = old_capability["name"]
try:
project = old_capability["project"]
except:
project = "TODO"
tests = old_capability["tests"]
for test in tests:
try:
flag = old_capability["tests"][test]["flag"]
except:
flag = None
new_capability_name = new_caps[test]["capability"]
try:
capability = capabilities[new_capability_name]
except:
capability = {}
capability["achievements"] = set()
capability["admin"] = set()
capability["required-since"] = set()
capability["description"] = set()
capability["project"] = set()
capability["tests"] = {}
for achievement in achievements:
capability["achievements"].add(achievement)
capability["admin"].add(str(admin))
capability["required-since"].add(required_since)
capability["description"].add(description)
capability["project"].add(project)
capability["tests"][test] = tests[test]
capabilities[new_capability_name] = capability
for capability in capabilities:
cap = capabilities[capability]
cap["achievements"] = list(cap["achievements"])
cap["admin"] = ", ".join(cap["admin"])
cap["required-since"] = ", ".join(cap["required-since"])
cap["description"] = ", ".join(cap["description"])
cap["project"] = ", ".join(cap["project"])
print json.dumps(capabilities, sort_keys=True, indent=2,
separators=(',', ': '))