init
This commit is contained in:
156
tools/bootstrap_repositories.py
Normal file
156
tools/bootstrap_repositories.py
Normal file
File diff suppressed because it is too large
Load Diff
22
tools/convert_data.py
Normal file
22
tools/convert_data.py
Normal file
@ -0,0 +1,22 @@
|
||||
import re
|
||||
|
||||
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
|
||||
link = doc.get("link")
|
||||
if link:
|
||||
print(f"Parsing {link}")
|
||||
# (p1, p2) = link.split("/")
|
||||
doc["link"] = re.sub(r"/(.*)/(.*)/", r"/\2/\1/", link)
|
||||
|
||||
_yaml = YAML()
|
||||
_yaml.indent(mapping=2, sequence=4, offset=2)
|
||||
with open("new.yaml", "w") as fd:
|
||||
_yaml.dump(new_data, fd)
|
477
tools/generate_doc_confpy.py
Normal file
477
tools/generate_doc_confpy.py
Normal file
File diff suppressed because it is too large
Load Diff
186
tools/generate_doc_gitcontrol_repos.py
Normal file
186
tools/generate_doc_gitcontrol_repos.py
Normal file
File diff suppressed because it is too large
Load Diff
38
tools/generate_docexports_data.py
Normal file
38
tools/generate_docexports_data.py
Normal file
@ -0,0 +1,38 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import sys
|
||||
|
||||
from ruamel.yaml import YAML
|
||||
|
||||
import otc_metadata.services
|
||||
|
||||
|
||||
def main():
|
||||
data = otc_metadata.services.Services()
|
||||
data._sort_data()
|
||||
|
||||
docs = data.docs_html_by_category("internal")
|
||||
|
||||
# Filter out documents with "disable_import": True
|
||||
for category, services in docs['categories'].items():
|
||||
for service in services:
|
||||
filtered_docs = []
|
||||
|
||||
for doc in service['docs']:
|
||||
# Check if the document doesnt have 'disable_import' on True
|
||||
if not doc.get('disable_import'):
|
||||
filtered_docs.append(doc)
|
||||
|
||||
service['docs'] = filtered_docs
|
||||
|
||||
_yaml = YAML()
|
||||
_yaml.indent(mapping=2, sequence=4, offset=2)
|
||||
sys.stdout.write(
|
||||
"# Auto-generated by otc_metadata.generate_docexports.data\n"
|
||||
)
|
||||
_yaml.dump(docs, sys.stdout)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
158
tools/index_metadata.py
Normal file
158
tools/index_metadata.py
Normal file
File diff suppressed because it is too large
Load Diff
73
tools/open_doc_issue.py
Normal file
73
tools/open_doc_issue.py
Normal file
@ -0,0 +1,73 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import argparse
|
||||
# import re
|
||||
import requests
|
||||
# import sys
|
||||
|
||||
import otc_metadata.services
|
||||
|
||||
api_session = requests.Session()
|
||||
|
||||
|
||||
def open_issue(args, repository, issue_data):
|
||||
req = dict(
|
||||
title=issue_data["title"], body=issue_data["body"].replace("\\n", "\n")
|
||||
)
|
||||
if "assignees" in issue_data:
|
||||
req["assignees"] = issue_data["assignees"]
|
||||
if "labels" in issue_data:
|
||||
req["labels"] = issue_data["labels"]
|
||||
print(req)
|
||||
rsp = api_session.post(
|
||||
f"{args.api_url}/repos/{repository}/issues", json=req
|
||||
)
|
||||
if rsp.status_code != 201:
|
||||
print(rsp.text)
|
||||
print(
|
||||
f"Going to open issue with title {issue_data['title']} in {repository}"
|
||||
)
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(
|
||||
description="Open Issue for every document."
|
||||
)
|
||||
parser.add_argument("token", metavar="token", help="API token")
|
||||
parser.add_argument("--api-url", help="API base url of the Git hoster")
|
||||
parser.add_argument("--environment", help="Environment for the repository")
|
||||
parser.add_argument("--title", required=True, help="Issue title")
|
||||
parser.add_argument("--body", required=True, help="Issue body")
|
||||
parser.add_argument(
|
||||
"--repo",
|
||||
help="Repository to report issue in (instead of doc repository).",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--assignee",
|
||||
help="Issue assignee to use instead of document service assignees.",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--labels",
|
||||
help="Issue labels to use (comma separated list of label IDs).",
|
||||
)
|
||||
args = parser.parse_args()
|
||||
data = otc_metadata.services.Services()
|
||||
api_session.headers.update({"Authorization": f"token {args.token}"})
|
||||
|
||||
for doc in data.all_docs_full(environment=args.environment):
|
||||
issue_data = dict(
|
||||
title=args.title.format(**doc),
|
||||
body=args.body.format(**doc),
|
||||
repository=doc["repository"],
|
||||
)
|
||||
if "assignees" in doc:
|
||||
issue_data["assignees"] = doc["assignees"]
|
||||
if args.assignee:
|
||||
issue_data["assignees"] = [args.assignee]
|
||||
if args.labels:
|
||||
issue_data["labels"] = [int(x) for x in args.labels.split(",")]
|
||||
open_issue(args, args.repo or doc["repository"], issue_data)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
9
tools/sort_metadata.py
Normal file
9
tools/sort_metadata.py
Normal file
@ -0,0 +1,9 @@
|
||||
# import copy
|
||||
|
||||
import otc_metadata.services
|
||||
# from ruamel.yaml import YAML
|
||||
|
||||
data = otc_metadata.services.Services()
|
||||
|
||||
data._sort_data()
|
||||
data._rewrite_data()
|
41
tools/split_metadata.py
Normal file
41
tools/split_metadata.py
Normal file
@ -0,0 +1,41 @@
|
||||
# import copy
|
||||
|
||||
from pathlib import Path
|
||||
import yaml
|
||||
|
||||
import otc_metadata
|
||||
|
||||
data = otc_metadata.services.Services()
|
||||
|
||||
for item in data.all_docs:
|
||||
with open(
|
||||
Path(
|
||||
otc_metadata.data.DATA_DIR,
|
||||
"documents",
|
||||
f"{item['service_type']}-{item['type']}.yaml",
|
||||
),
|
||||
"w",
|
||||
) as fp:
|
||||
yaml.dump(item, fp, explicit_start=True)
|
||||
|
||||
for item in data.all_services:
|
||||
with open(
|
||||
Path(
|
||||
otc_metadata.data.DATA_DIR,
|
||||
"services",
|
||||
f"{item['service_type']}.yaml",
|
||||
),
|
||||
"w",
|
||||
) as fp:
|
||||
yaml.dump(item, fp, explicit_start=True)
|
||||
|
||||
for item in data.service_categories:
|
||||
with open(
|
||||
Path(
|
||||
otc_metadata.data.DATA_DIR,
|
||||
"service_categories",
|
||||
f"{item['name']}.yaml",
|
||||
),
|
||||
"w",
|
||||
) as fp:
|
||||
yaml.dump(item, fp, explicit_start=True)
|
201
tools/sync_doc_repo.py
Normal file
201
tools/sync_doc_repo.py
Normal file
File diff suppressed because it is too large
Load Diff
294
tools/update_zuul_project_configs.py
Normal file
294
tools/update_zuul_project_configs.py
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user