Merge branch 'master' into markjh/document_v1_rooms_api

This commit is contained in:
Mark Haines 2015-09-17 15:25:00 +01:00
commit 315f97e36b
38 changed files with 136 additions and 154 deletions

View file

@ -283,17 +283,31 @@ class MatrixUnits(Units):
def load_common_event_fields(self):
path = "../event-schemas/schema/v1/core"
event_types = {}
with open(path, "r") as f:
core_json = json.loads(f.read())
for event_type in core_json["definitions"]:
for (root, dirs, files) in os.walk(path):
for filename in files:
if not filename.endswith(".json"):
continue
event_type = filename[:-5] # strip the ".json"
filepath = os.path.join(root, filename)
with open(filepath) as f:
try:
event_info = json.load(f)
except Exception as e:
raise ValueError(
"Error reading file %r" % (filepath,), e
)
if "event" not in event_type:
continue # filter ImageInfo and co
event_info = core_json["definitions"][event_type]
table = {
"title": event_info["title"],
"desc": event_info["description"],
"rows": []
}
for prop in sorted(event_info["properties"]):
row = {
"key": prop,
@ -301,6 +315,7 @@ class MatrixUnits(Units):
"desc": event_info["properties"][prop].get("description","")
}
table["rows"].append(row)
event_types[event_type] = table
return event_types