otc-metadata/tools/convert_data.py

32 lines
758 B
Python

import copy
import otc_metadata.services
from ruamel.yaml import YAML
data = otc_metadata.services.Services()
new_data = data._service_data
services = data.service_dict
for srv in new_data["services"]:
if len(srv["repositories"]) ==1:
r1 = srv["repositories"][0]
srv["repositories"] = [
{
"environment": r1["environment"],
"repo": r1["repo"],
"type": r1["type"]
},
{
"environment": "public",
"repo": 'opentelekomcloud-' + r1["repo"],
"type": "github"
},
]
_yaml = YAML()
_yaml.indent(mapping=2, sequence=4, offset=2)
with open('new.yaml', 'w') as fd:
_yaml.dump(new_data, fd)