python-ox fixes
This commit is contained in:
parent
0ec7e7cc9e
commit
ab9940425c
2 changed files with 11 additions and 2 deletions
|
|
@ -294,7 +294,7 @@ def copy_file(source, target, verbose=False):
|
|||
def read_file(file, verbose=False):
|
||||
if verbose:
|
||||
print('reading', file)
|
||||
f = open(file)
|
||||
f = open(file, 'rb')
|
||||
data = f.read()
|
||||
f.close()
|
||||
return data
|
||||
|
|
@ -309,8 +309,10 @@ def read_json(file, verbose=False):
|
|||
def write_file(file, data, verbose=False):
|
||||
if verbose:
|
||||
print('writing', file)
|
||||
if not isinstance(data, bytes):
|
||||
data = data.encode('utf-8')
|
||||
write_path(file)
|
||||
f = open(file, 'w')
|
||||
f = open(file, 'wb')
|
||||
f.write(data)
|
||||
f.close()
|
||||
return len(data)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue