forked from infra/otc-metadata
29 lines
712 B
Python
29 lines
712 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 doc in new_data["documents"]:
|
|
hc_location = None
|
|
if "type" in doc:
|
|
if doc["type"] == "api-ref":
|
|
hc_location = "api"
|
|
elif doc["type"] == "umn":
|
|
hc_location = "usermanual"
|
|
elif doc["type"] == "dev":
|
|
hc_location = "devg"
|
|
if hc_location:
|
|
hc_location += f"/{doc['service_type']}"
|
|
doc["hc_location"] = hc_location
|
|
|
|
|
|
_yaml = YAML()
|
|
_yaml.indent(mapping=2, sequence=4, offset=2)
|
|
with open('new.yaml', 'w') as fd:
|
|
_yaml.dump(new_data, fd)
|