Skip to content

Commit

Permalink
hotfix for FileIO
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashvin-Ranjan committed Jun 27, 2022
1 parent d27023e commit e3f3db1
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions python/libraries/FileIO.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

def write(scope):
async def out(p, content):
path = os.path.relpath(p, start=scope.file_path)
path = os.path.join(scope.base_path, p)
try:
if not os.path.exists(os.path.split(os.path.abspath(path))[0]):
os.mkdir(os.path.split(os.path.abspath(path))[0])
Expand All @@ -23,31 +23,31 @@ async def out(p, content):

def append(scope):
async def out(p, content):
path = os.path.relpath(p, start=scope.file_path)
path = os.path.join(scope.base_path, p)
try:
if not os.path.exists(os.path.split(os.path.abspath(path))[0]):
os.mkdir(os.path.split(os.path.abspath(path))[0])
async with async_open(path, "a+", encoding="utf-8") as f:
await f.write(content)
except:
pass
return out


def read(scope):
async def out(p):
path = os.path.relpath(p, start=scope.file_path)
path = os.path.join(scope.base_path, p)
try:
async with async_open(path, "r", encoding="utf-8") as f:
return yes(await f.read())
except:
return none

return ()
return out

def writeBytes(scope):
async def out(p, content):
path = os.path.relpath(p, start=scope.file_path)
path = os.path.join(scope.base_path, p)
try:
if not os.path.exists(os.path.split(os.path.abspath(path))[0]):
os.mkdir(os.path.split(os.path.abspath(path))[0])
Expand All @@ -62,7 +62,7 @@ async def out(p, content):

def appendBytes(scope):
async def out(p, content):
path = os.path.relpath(p, start=scope.file_path)
path = os.path.join(scope.base_path, p)
try:
if not os.path.exists(os.path.split(os.path.abspath(path))[0]):
os.mkdir(os.path.split(os.path.abspath(path))[0])
Expand All @@ -77,7 +77,7 @@ async def out(p, content):

def readBytes(scope):
async def out(p):
path = os.path.relpath(p, start=scope.file_path)
path = os.path.join(scope.base_path, p)
try:
async with async_open(path, "rb") as f:
return yes(list(await f.read()))
Expand All @@ -88,7 +88,7 @@ async def out(p):

def getFiles(scope):
async def out(p):
path = os.path.relpath(p, start=scope.file_path)
path = os.path.join(scope.base_path, p)
can_run = os.environ.get("FILE_ALLOW") == "true"
if not can_run:
return []
Expand Down

0 comments on commit e3f3db1

Please sign in to comment.