More scripts

This commit is contained in:
2025-04-16 08:42:23 +00:00
parent 8edc99df52
commit 7f1b8f4d56
3 changed files with 56 additions and 15 deletions

View File

@ -141,7 +141,7 @@ class Services(object):
res[cat]["docs"].append(res_doc)
return res
def service_types_with_doc_types(self, environment=None):
def service_types_with_doc_types(self, cloud_environment, environment=None):
"""Retrieve type and title from services and corresponding docs.
As well as a list of all available doc types with title.
@ -154,6 +154,13 @@ class Services(object):
if "environment" in service:
if service["environment"] != environment:
continue
cloud_environment_service_check = False
for cloud_environment_service in service["cloud_environments"]:
if cloud_environment_service["name"] == cloud_environment:
cloud_environment_service_check = True
break
if cloud_environment_service_check is False:
continue
if not service["service_title"]:
continue
if not service["service_type"]:
@ -164,6 +171,13 @@ class Services(object):
if "environment" in doc:
if doc["environment"] != environment:
continue
cloud_environment_doc_check = False
for cloud_environment_doc in doc["cloud_environments"]:
if cloud_environment_doc["name"] == cloud_environment:
cloud_environment_doc_check = True
break
if cloud_environment_doc_check is False:
continue
if doc["service_type"] == service["service_type"]:
doc_list.append({
"title": doc["title"],
@ -239,22 +253,31 @@ class Services(object):
def all_docs_full(self, environment):
"""Return list or documents with full service data"""
res = []
services = self.service_dict
for doc in self.all_docs:
if not doc["service_type"] in services:
print(f"No service type {doc['service_type']}")
cat = doc["service_type"]
service = services.get(cat)
if not service:
warnings.warn("No Service defition of type %s" % (cat))
continue
service = services[doc["service_type"]]
res_doc = copy.deepcopy(doc)
res_doc.update(**service)
if environment:
for srv_env in service["repositories"]:
if srv_env.get("environment") == environment:
res_doc["repository"] = srv_env["repo"]
for srv_assignees in service.get("assignees", []):
if srv_assignees.get("environment") == environment:
res_doc["assignees"] = srv_assignees["names"]
yield res_doc
for repositories in self.all_repositories:
if repositories["service_type"] == service["service_type"]:
res_doc = copy.deepcopy(doc)
res_doc["repositories"] = repositories["repositories"]
res_doc.update(**service)
# Get the cloud environments from the document instead of service
res_doc["cloud_environments"] = doc["cloud_environments"]
if environment:
repo_env_filter = []
for repo in repositories["repositories"]:
if repo["environment"] == environment:
repo_env_filter.append(repo)
res_doc["repositories"] = repo_env_filter
res.append(res_doc)
return res
def docs_html_by_category(self, environment, cloud_environment):
"""Generate structure for doc-exports repository"""