mirror of
https://github.com/YunoHost/moulinette.git
synced 2024-09-03 20:06:31 +02:00
[enh] Support bytes in write_to_file
This commit is contained in:
parent
d0687b204b
commit
6e714314f0
1 changed files with 2 additions and 2 deletions
|
@ -119,7 +119,7 @@ def write_to_file(file_path, data, file_mode="w"):
|
||||||
file_mode -- Mode used when writing the file. Option meant to be used
|
file_mode -- Mode used when writing the file. Option meant to be used
|
||||||
by append_to_file to avoid duplicating the code of this function.
|
by append_to_file to avoid duplicating the code of this function.
|
||||||
"""
|
"""
|
||||||
assert isinstance(data, str) or isinstance(
|
assert isinstance(data, str) or isinstance(data, bytes) or isinstance(
|
||||||
data, list
|
data, list
|
||||||
), "Error: data '%s' should be either a string or a list but is of type '%s'" % (
|
), "Error: data '%s' should be either a string or a list but is of type '%s'" % (
|
||||||
data,
|
data,
|
||||||
|
@ -136,7 +136,7 @@ def write_to_file(file_path, data, file_mode="w"):
|
||||||
)
|
)
|
||||||
|
|
||||||
# If data is a list, check elements are strings and build a single string
|
# If data is a list, check elements are strings and build a single string
|
||||||
if not isinstance(data, str):
|
if isinstance(data, list):
|
||||||
for element in data:
|
for element in data:
|
||||||
assert isinstance(
|
assert isinstance(
|
||||||
element, str
|
element, str
|
||||||
|
|
Loading…
Reference in a new issue