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
commit 4ed88512e4
89 changed files with 759 additions and 894 deletions

View file

@ -24,10 +24,10 @@ import tempfile
import re
from ansible.errors import AnsibleError
from ansible.module_utils._text import to_native, to_text
from ansible.plugins.action import ActionBase
from ansible.utils.boolean import boolean
from ansible.utils.hashing import checksum_s
from ansible.utils.unicode import to_str, to_unicode
class ActionModule(ActionBase):
@ -42,7 +42,7 @@ class ActionModule(ActionBase):
delimit_me = False
add_newline = False
for f in (to_unicode(p, errors='strict') for p in sorted(os.listdir(src_path))):
for f in (to_text(p, errors='surrogate_or_strict') for p in sorted(os.listdir(src_path))):
if compiled_regexp and not compiled_regexp.search(f):
continue
fragment = u"%s/%s" % (src_path, f)
@ -114,7 +114,7 @@ class ActionModule(ActionBase):
src = self._find_needle('files', src)
except AnsibleError as e:
result['failed'] = True
result['msg'] = to_str(e)
result['msg'] = to_native(e)
return result
if not os.path.isdir(src):