From 60603c3213810893f6ea97d9872ddfb444163d34 Mon Sep 17 00:00:00 2001 From: Jesse Pretorius Date: Fri, 15 Apr 2016 11:33:25 +0100 Subject: [PATCH] Adjust ansible-role-requirements-editor file open options This implements more correct file open options. While this is not strictly required it does appear to make the script behave more consistently across different platforms. The patch also renames the file name and related content to ensure that the tool is correctly spelled. Change-Id: Idde0141691e1008bead802bd6f3759c12e37b02b --- ...ements-editer.py => ansible-role-requirements-editor.py} | 6 +++--- scripts/sources-branch-updater.sh | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) rename scripts/{ansible-role-requirements-editer.py => ansible-role-requirements-editor.py} (94%) diff --git a/scripts/ansible-role-requirements-editer.py b/scripts/ansible-role-requirements-editor.py similarity index 94% rename from scripts/ansible-role-requirements-editer.py rename to scripts/ansible-role-requirements-editor.py index 625012ba40..a2096b81f4 100755 --- a/scripts/ansible-role-requirements-editer.py +++ b/scripts/ansible-role-requirements-editor.py @@ -47,7 +47,7 @@ def main(): # Setup argument parsing parser = argparse.ArgumentParser( - description='ansible-role-requirements.yml CLI editer', + description='ansible-role-requirements.yml CLI editor', epilog='Licensed "Apache 2.0"') parser.add_argument( @@ -82,7 +82,7 @@ def main(): args = parser.parse_args() # Read the ansible-role-requirements.yml file into memory - with open(args.file, "r+") as role_req_file: + with open(args.file, "r") as role_req_file: reqs = yaml.safe_load(role_req_file) # Loop through the list to find the applicable role @@ -94,7 +94,7 @@ def main(): role_data['src'] = args.src # Write out the resulting file - with open(args.file, "r+") as role_req_file: + with open(args.file, "w") as role_req_file: try: yaml.dump(reqs, role_req_file, default_flow_style=False) except yaml.YAMLError as exc: diff --git a/scripts/sources-branch-updater.sh b/scripts/sources-branch-updater.sh index b1b6269574..a3d84a6448 100755 --- a/scripts/sources-branch-updater.sh +++ b/scripts/sources-branch-updater.sh @@ -212,7 +212,7 @@ if [[ "${OSA_BRANCH}" != "master" ]]; then fi # Now use the information we have to update the ansible-role-requirements file - $(dirname ${0})/ansible-role-requirements-editer.py -f ansible-role-requirements.yml -n "${role_name}" -v "${role_version}" + $(dirname ${0})/ansible-role-requirements-editor.py -f ansible-role-requirements.yml -n "${role_name}" -v "${role_version}" done echo "Completed updating ansible-role-requirements.yml" else