Move uses of to_bytes, to_text, to_native to use the module_utils version (#17423)

We couldn't copy to_unicode, to_bytes, to_str into module_utils because
of licensing.  So once created it we had two sets of functions that did
the same things but had different implementations.  To remedy that, this
change removes the ansible.utils.unicode versions of those functions.
This commit is contained in:
Toshio Kuratomi 2016-09-06 22:54:17 -07:00 committed by GitHub
parent 7a9395b5e0
commit 4ed88512e4
89 changed files with 759 additions and 894 deletions

View file

@ -26,10 +26,12 @@ import glob
import urlparse
from ansible.plugins.action import ActionBase
from ansible.utils.unicode import to_unicode
from ansible.module_utils._text import to_text
PRIVATE_KEYS_RE = re.compile('__.+__')
class ActionModule(ActionBase):
TRANSFERS_FILES = False
@ -56,7 +58,6 @@ class ActionModule(ActionBase):
result['__backup__'])
result['backup_path'] = filepath
# strip out any keys that have two leading and two trailing
# underscore characters
for key in result.keys():
@ -98,7 +99,7 @@ class ActionModule(ActionBase):
try:
with open(source, 'r') as f:
template_data = to_unicode(f.read())
template_data = to_text(f.read())
except IOError:
return dict(failed=True, msg='unable to load src file')
@ -114,5 +115,3 @@ class ActionModule(ActionBase):
searchpath.append(os.path.dirname(source))
self._templar.environment.loader.searchpath = searchpath
self._task.args['src'] = self._templar.template(template_data)