feat: inject parameters into enc output

- add the enc_role parameter as a copy of classes
- add the enc_env parameter as a copy of environment
This commit is contained in:
Ben Vincent 2023-11-04 20:09:21 +11:00
parent 4c8483326e
commit 7ca110dbf9

16
enc.py
View File

@ -28,15 +28,29 @@ def main():
with open(file_path, "r") as f:
data = yaml.safe_load(f)
# If the environment is 'testing', remove it from the output
# Initialize 'parameters' if it doesn't exist
if "parameters" not in data:
data["parameters"] = {}
# Add 'enc_role' parameter with classes data
if "classes" in data:
data["parameters"]["enc_role"] = data["classes"]
# Copy the environment to the parameters, if it exists
if data.get("environment"):
data["parameters"]["enc_env"] = data["environment"]
# If the environment is 'testing', remove it
if data.get("environment") == "testing":
data.pop("environment", None)
# Print the YAML without the 'environment' if it was 'testing'
print(yaml.dump(data))
except IOError as e:
print("Could not open {}: {}".format(file_path, e), file=sys.stderr)
sys.exit(1)
except yaml.YAMLError as e:
print("Error in {}: {}".format(file_path, e), file=sys.stderr)
sys.exit(1)