Merge pull request 'feat: inject parameters into enc output' (#22) from neoloc/inject_parameters into master
Reviewed-on: #22
This commit is contained in:
commit
28b42f81b5
16
enc.py
16
enc.py
@ -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)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user