mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-10-05 07:54:00 -07:00
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:
parent
7a9395b5e0
commit
4ed88512e4
89 changed files with 759 additions and 894 deletions
|
@ -22,12 +22,6 @@ import pwd
|
|||
import grp
|
||||
import stat
|
||||
|
||||
from ansible.plugins.lookup import LookupBase
|
||||
from ansible.utils.unicode import to_str
|
||||
|
||||
from __main__ import display
|
||||
warning = display.warning
|
||||
|
||||
HAVE_SELINUX=False
|
||||
try:
|
||||
import selinux
|
||||
|
@ -35,6 +29,11 @@ try:
|
|||
except ImportError:
|
||||
pass
|
||||
|
||||
from ansible.plugins.lookup import LookupBase
|
||||
from ansible.module_utils._text import to_native
|
||||
|
||||
from __main__ import display
|
||||
|
||||
|
||||
# If selinux fails to find a default, return an array of None
|
||||
def selinux_context(path):
|
||||
|
@ -43,7 +42,7 @@ def selinux_context(path):
|
|||
try:
|
||||
# note: the selinux module uses byte strings on python2 and text
|
||||
# strings on python3
|
||||
ret = selinux.lgetfilecon_raw(to_str(path))
|
||||
ret = selinux.lgetfilecon_raw(to_native(path))
|
||||
except OSError:
|
||||
return context
|
||||
if ret[0] != -1:
|
||||
|
@ -60,7 +59,7 @@ def file_props(root, path):
|
|||
try:
|
||||
st = os.lstat(abspath)
|
||||
except OSError as e:
|
||||
warning('filetree: Error using stat() on path %s (%s)' % (abspath, e))
|
||||
display.warning('filetree: Error using stat() on path %s (%s)' % (abspath, e))
|
||||
return None
|
||||
|
||||
ret = dict(root=root, path=path)
|
||||
|
@ -74,7 +73,7 @@ def file_props(root, path):
|
|||
ret['state'] = 'file'
|
||||
ret['src'] = abspath
|
||||
else:
|
||||
warning('filetree: Error file type of %s is not supported' % abspath)
|
||||
display.warning('filetree: Error file type of %s is not supported' % abspath)
|
||||
return None
|
||||
|
||||
ret['uid'] = st.st_uid
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue