mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 17:09:03 +00:00
Handle list of lines instead of strings in file.line func
In `Fluorine`, in order to better handle line endings, the "body" variable has been changed to a list of strings. Therefore, we need to handle encoding or decoding the elements in the list, rather than using the `stringutils` functions.
This commit is contained in:
parent
b9ddd53b04
commit
475f075d8e
@ -2047,10 +2047,10 @@ def line(path, content=None, match=None, mode=None, location=None,
|
||||
# Make sure we match the file mode from salt.utils.files.fopen
|
||||
if six.PY2 and salt.utils.platform.is_windows():
|
||||
mode = 'wb'
|
||||
body = salt.utils.stringutils.to_bytes(body)
|
||||
body = salt.utils.data.encode_list(body)
|
||||
else:
|
||||
mode = 'w'
|
||||
body = salt.utils.stringutils.to_str(body)
|
||||
body = salt.utils.data.decode_list(body, to_str=True)
|
||||
fh_ = salt.utils.atomicfile.atomic_open(path, mode)
|
||||
fh_.write(''.join(body))
|
||||
finally:
|
||||
|
Loading…
Reference in New Issue
Block a user