mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-10-09 18:04:02 -07:00
Move a path being passed around as a byte string to being passed around as a text string. (#17190)
This is enough to get minimal copy module working on python3 We have t omodify dataloader's path_dwim_relative_stack and everything that calls it to use text paths instead of byte string paths
This commit is contained in:
parent
20bde8f549
commit
313d4b2c9e
12 changed files with 94 additions and 58 deletions
|
@ -21,6 +21,7 @@ import shelve
|
|||
|
||||
from ansible.errors import AnsibleError
|
||||
from ansible.plugins.lookup import LookupBase
|
||||
from ansible.utils.unicode import to_bytes, to_unicode
|
||||
|
||||
class LookupModule(LookupBase):
|
||||
|
||||
|
@ -29,7 +30,7 @@ class LookupModule(LookupBase):
|
|||
"""
|
||||
Read the value of "key" from a shelve file
|
||||
"""
|
||||
d = shelve.open(shelve_filename)
|
||||
d = shelve.open(to_bytes(shelve_filename))
|
||||
res = d.get(key, None)
|
||||
d.close()
|
||||
return res
|
||||
|
@ -65,7 +66,7 @@ class LookupModule(LookupBase):
|
|||
if res is None:
|
||||
raise AnsibleError("Key %s not found in shelve file %s" % (key, file))
|
||||
# Convert the value read to string
|
||||
ret.append(str(res))
|
||||
ret.append(to_unicode(res))
|
||||
break
|
||||
else:
|
||||
raise AnsibleError("Could not locate shelve file in lookup: %s" % file)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue