summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Butcher <abutcher@redhat.com>2016-09-22 11:19:12 -0400
committerAndrew Butcher <abutcher@redhat.com>2016-09-28 15:30:47 -0400
commit70dd1bb1e94530741d6524eba57166a7457ec7f2 (patch)
tree63c8bcc7b7853f3c3066f2ddc979ae82a2d3529f
parent37788eb7590babf79bbec52fb29211ada7136878 (diff)
downloadopenshift-70dd1bb1e94530741d6524eba57166a7457ec7f2.tar.gz
openshift-70dd1bb1e94530741d6524eba57166a7457ec7f2.tar.bz2
openshift-70dd1bb1e94530741d6524eba57166a7457ec7f2.tar.xz
openshift-70dd1bb1e94530741d6524eba57166a7457ec7f2.zip
Use ansible.module_utils._text.to_text instead of ansible.utils.unicode.to_unicode.
-rw-r--r--filter_plugins/oo_filters.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/filter_plugins/oo_filters.py b/filter_plugins/oo_filters.py
index 1c12f2e07..39e6b0a0b 100644
--- a/filter_plugins/oo_filters.py
+++ b/filter_plugins/oo_filters.py
@@ -17,9 +17,17 @@ import re
import json
import yaml
from ansible.parsing.yaml.dumper import AnsibleDumper
-from ansible.utils.unicode import to_unicode
from urlparse import urlparse
+try:
+ # ansible-2.2
+ # ansible.utils.unicode.to_unicode is deprecated in ansible-2.2,
+ # ansible.module_utils._text.to_text should be used instead.
+ from ansible.module_utils._text import to_text
+except ImportError:
+ # ansible-2.1
+ from ansible.utils.unicode import to_unicode as to_text
+
# Disabling too-many-public-methods, since filter methods are necessarily
# public
# pylint: disable=too-many-public-methods
@@ -626,7 +634,7 @@ class FilterModule(object):
default_flow_style=False,
Dumper=AnsibleDumper, **kw)
padded = "\n".join([" " * level * indent + line for line in transformed.splitlines()])
- return to_unicode("\n{0}".format(padded))
+ return to_text("\n{0}".format(padded))
except Exception as my_e:
raise errors.AnsibleFilterError('Failed to convert: %s' % my_e)