2024-07-11 13:37:07 +02:00
|
|
|
import csv
|
|
|
|
import os
|
|
|
|
|
2024-08-20 18:55:12 +02:00
|
|
|
def get_blacklisted(blacklist_dir_path):
|
|
|
|
blacklisted = set()
|
|
|
|
if os.path.exists(blacklist_dir_path):
|
2024-08-22 17:55:05 +02:00
|
|
|
for blacklist in os.listdir(blacklist_dir_path):
|
|
|
|
if not os.path.isdir(blacklist):
|
|
|
|
blacklist_csv_path = os.path.join(blacklist_dir_path, blacklist)
|
|
|
|
with open(blacklist_csv_path, "r") as csv_file:
|
|
|
|
spamreader = csv.reader(csv_file, delimiter=",")
|
|
|
|
for row in spamreader:
|
|
|
|
blacklisted.add(row[0])
|
2024-08-20 18:55:12 +02:00
|
|
|
return blacklisted
|
|
|
|
|
|
|
|
def get_artifacts_to_build(artifacts_folder, blacklist_dir_path):
|
|
|
|
blacklisted = get_blacklisted(blacklist_dir_path)
|
|
|
|
all_artifacts = set([os.path.splitext(a)[0] for a in os.listdir(artifacts_folder) if not os.path.isdir(os.path.join(artifacts_folder, a))])
|
2024-08-22 18:37:44 +02:00
|
|
|
artifacts_to_build = list(all_artifacts.difference(blacklisted))
|
|
|
|
if artifacts_to_build != []:
|
|
|
|
return list(all_artifacts.difference(blacklisted))
|
|
|
|
else:
|
|
|
|
raise(Exception(f"There is no artifact to build! Either no artifact configuration files have been found, or they have all been blacklisted."))
|