diff options
author | Kenny Woodson <kwoodson@redhat.com> | 2017-02-16 15:44:26 -0500 |
---|---|---|
committer | Kenny Woodson <kwoodson@redhat.com> | 2017-02-16 15:46:14 -0500 |
commit | d4db2dd279916c2a1f73c236deed444fed5cc740 (patch) | |
tree | 9e2185c969136790788f8ef21435df480719dcf3 /roles/lib_openshift/src/lib/base.py | |
parent | 42af186c6f961a9a7cd76abc4ac423d9141bded2 (diff) | |
download | openshift-d4db2dd279916c2a1f73c236deed444fed5cc740.tar.gz openshift-d4db2dd279916c2a1f73c236deed444fed5cc740.tar.bz2 openshift-d4db2dd279916c2a1f73c236deed444fed5cc740.tar.xz openshift-d4db2dd279916c2a1f73c236deed444fed5cc740.zip |
Fixed tests for pyyaml vs ruamel. Added import logic. Fixed safe load.
Diffstat (limited to 'roles/lib_openshift/src/lib/base.py')
-rw-r--r-- | roles/lib_openshift/src/lib/base.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/roles/lib_openshift/src/lib/base.py b/roles/lib_openshift/src/lib/base.py index a895b40b3..0b37862c9 100644 --- a/roles/lib_openshift/src/lib/base.py +++ b/roles/lib_openshift/src/lib/base.py @@ -295,7 +295,10 @@ class Utils(object): tmp = Utils.create_tmpfile(prefix=rname) if ftype == 'yaml': - Utils._write(tmp, yaml.dump(data, Dumper=yaml.RoundTripDumper)) + if hasattr(yaml, 'RoundTripDumper'): + Utils._write(tmp, yaml.dump(data, Dumper=yaml.RoundTripDumper)) + else: + Utils._write(tmp, yaml.safe_dump(data, default_flow_style=False)) elif ftype == 'json': Utils._write(tmp, json.dumps(data)) else: @@ -377,7 +380,10 @@ class Utils(object): contents = sfd.read() if sfile_type == 'yaml': - contents = yaml.load(contents, yaml.RoundTripLoader) + if hasattr(yaml, 'RoundTripLoader'): + contents = yaml.load(contents, yaml.RoundTripLoader) + else: + contents = yaml.safe_load(contents) elif sfile_type == 'json': contents = json.loads(contents) |