Merge pull request #932 from NMD03/formatted

Ignore deprecated galaxies + bugfix
pull/933/head v2.4.185
Alexandre Dulaunoy 2024-02-16 14:14:09 +01:00 committed by GitHub
commit a94fd523db
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 51 additions and 17 deletions

View File

@ -10,6 +10,8 @@ import validators
CLUSTER_PATH = "../../clusters" CLUSTER_PATH = "../../clusters"
SITE_PATH = "./site/docs" SITE_PATH = "./site/docs"
GALAXY_PATH = "../../galaxies"
FILES_TO_IGNORE = [] # if you want to skip a specific cluster in the generation FILES_TO_IGNORE = [] # if you want to skip a specific cluster in the generation
@ -63,6 +65,7 @@ class Galaxy:
def __init__( def __init__(
self, cluster_list: List[dict], authors, description, name, json_file_name self, cluster_list: List[dict], authors, description, name, json_file_name
): ):
self.cluster_list = cluster_list self.cluster_list = cluster_list
self.authors = authors self.authors = authors
self.description = description self.description = description
@ -203,7 +206,9 @@ class Cluster:
if meta not in excluded_meta: if meta not in excluded_meta:
self.entry += f" | {meta} | {self.meta[meta]} |\n" self.entry += f" | {meta} | {self.meta[meta]} |\n"
def get_related_clusters(self, cluster_dict, depth=-1, visited=None, level=1): def get_related_clusters(
self, cluster_dict, depth=-1, visited=None, level=1, related_private_clusters={}
):
global public_relations_count global public_relations_count
global private_relations_count global private_relations_count
global private_clusters global private_clusters
@ -234,21 +239,31 @@ class Cluster:
private_relations_count += 1 private_relations_count += 1
if dest_uuid not in private_clusters: if dest_uuid not in private_clusters:
private_clusters.append(dest_uuid) private_clusters.append(dest_uuid)
related_clusters.append( if dest_uuid in related_private_clusters:
( related_clusters.append(
self, (
Cluster( self,
value="Private Cluster", related_private_clusters[dest_uuid],
uuid=dest_uuid, level,
date=None, )
description=None,
related_list=None,
meta=None,
galaxie=None,
),
level,
) )
) else:
related_clusters.append(
(
self,
Cluster(
value="Private Cluster",
uuid=dest_uuid,
date=None,
description=None,
related_list=None,
meta=None,
galaxie=None,
),
level,
)
)
related_private_clusters[dest_uuid] = related_clusters[-1][1]
continue continue
related_cluster = cluster_dict[dest_uuid] related_cluster = cluster_dict[dest_uuid]
@ -265,7 +280,13 @@ class Cluster:
if cluster["dest-uuid"] in cluster_dict: if cluster["dest-uuid"] in cluster_dict:
related_clusters += cluster_dict[ related_clusters += cluster_dict[
cluster["dest-uuid"] cluster["dest-uuid"]
].get_related_clusters(cluster_dict, new_depth, visited, level + 1) ].get_related_clusters(
cluster_dict,
new_depth,
visited,
level + 1,
related_private_clusters,
)
if empty_uuids > 0: if empty_uuids > 0:
empty_uuids_dict[self.value] = empty_uuids empty_uuids_dict[self.value] = empty_uuids
@ -370,9 +391,9 @@ class Cluster:
def create_index(galaxies): def create_index(galaxies):
index_output = INTRO index_output = INTRO
index_output += STATISTICS
for galaxie in galaxies: for galaxie in galaxies:
index_output += f"- [{galaxie.name}](./{galaxie.json_file_name}/index.md)\n" index_output += f"- [{galaxie.name}](./{galaxie.json_file_name}/index.md)\n"
index_output += STATISTICS
index_output += CONTRIBUTING index_output += CONTRIBUTING
return index_output return index_output
@ -482,8 +503,21 @@ def create_statistics(cluster_dict):
return statistic_output return statistic_output
def get_deprecated_galaxy_files():
deprecated_galaxy_files = []
for f in os.listdir(GALAXY_PATH):
with open(os.path.join(GALAXY_PATH, f)) as fr:
galaxy_json = json.load(fr)
if "namespace" in galaxy_json and galaxy_json["namespace"] == "deprecated":
deprecated_galaxy_files.append(f)
return deprecated_galaxy_files
def main(): def main():
start_time = time.time() start_time = time.time()
FILES_TO_IGNORE.extend(get_deprecated_galaxy_files())
galaxies_fnames = [] galaxies_fnames = []
for f in os.listdir(CLUSTER_PATH): for f in os.listdir(CLUSTER_PATH):
if ".json" in f and f not in FILES_TO_IGNORE: if ".json" in f and f not in FILES_TO_IGNORE: