Skip to content

Commit

Permalink
Added binary mode to the read function.
Browse files Browse the repository at this point in the history
Also removed unecessary closes from the file operations.
  • Loading branch information
piraz committed Jan 9, 2020
1 parent 8703df2 commit 10b4833
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions cartola/fs.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,20 +61,20 @@ def write(path, data, binary=False):
mode = "wb"
with open(path, mode) as f:
f.write(data)
f.close()


def read(path):
def read(path, binary=False):
""" Reads a file located at the given path. """
data = None
with open(path, 'r') as f:
mode = "w"
if binary:
mode = "wb"
with open(path, mode) as f:
data = f.read()
f.close()
return data


def touch(path):
""" Creates a file located at the given path. """
with open(path, 'a') as f:
os.utime(path, None)
f.close()

0 comments on commit 10b4833

Please sign in to comment.