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:
rallytime 2018-06-27 10:24:38 -04:00
parent b9ddd53b04
commit 475f075d8e
No known key found for this signature in database
GPG Key ID: E8F1A4B90D0DEA19

View File

@ -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 # Make sure we match the file mode from salt.utils.files.fopen
if six.PY2 and salt.utils.platform.is_windows(): if six.PY2 and salt.utils.platform.is_windows():
mode = 'wb' mode = 'wb'
body = salt.utils.stringutils.to_bytes(body) body = salt.utils.data.encode_list(body)
else: else:
mode = 'w' 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_ = salt.utils.atomicfile.atomic_open(path, mode)
fh_.write(''.join(body)) fh_.write(''.join(body))
finally: finally: