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:
parent
4c8483326e
commit
7ca110dbf9
16
enc.py
16
enc.py
@ -28,15 +28,29 @@ def main():
|
|||||||
with open(file_path, "r") as f:
|
with open(file_path, "r") as f:
|
||||||
data = yaml.safe_load(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":
|
if data.get("environment") == "testing":
|
||||||
data.pop("environment", None)
|
data.pop("environment", None)
|
||||||
|
|
||||||
# Print the YAML without the 'environment' if it was 'testing'
|
# Print the YAML without the 'environment' if it was 'testing'
|
||||||
print(yaml.dump(data))
|
print(yaml.dump(data))
|
||||||
|
|
||||||
except IOError as e:
|
except IOError as e:
|
||||||
print("Could not open {}: {}".format(file_path, e), file=sys.stderr)
|
print("Could not open {}: {}".format(file_path, e), file=sys.stderr)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
except yaml.YAMLError as e:
|
except yaml.YAMLError as e:
|
||||||
print("Error in {}: {}".format(file_path, e), file=sys.stderr)
|
print("Error in {}: {}".format(file_path, e), file=sys.stderr)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user