forked from infra/otc-metadata
28 lines
795 B
Python
28 lines
795 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"]:
|
|
service = services.get(doc["service_type"])
|
|
if not service:
|
|
continue
|
|
service_link = service["repositories"][0]["repo"].split('/')[1]
|
|
if doc["rst_location"].find("api-ref") >= 0:
|
|
doc["rst_location"] = "api-ref/source"
|
|
elif doc["rst_location"].find("umn") >= 0:
|
|
doc["rst_location"] = "umn/source"
|
|
doc["type"] = "umn"
|
|
elif doc["rst_location"].find("dev") >= 0:
|
|
doc["rst_location"] = "dev_guide/source"
|
|
|
|
_yaml = YAML()
|
|
_yaml.indent(mapping=2, sequence=4, offset=2)
|
|
with open('new.yaml', 'w') as fd:
|
|
_yaml.dump(new_data, fd)
|