Skip to content

Commit

Permalink
Added a common.s2b method
Browse files Browse the repository at this point in the history
  • Loading branch information
james-strauss-uwa committed Sep 23, 2020
1 parent 1990e2f commit 218b164
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions daliuge-common/dlg/common/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,18 @@ def b2s(b, enc='utf8'):
return b.decode(enc)
def u2s(u):
return u
def s2b(s, enc='utf-8'):
return s.encode(enc)
else:
def b2s(b, enc='utf8'):
return b
def u2s(u, enc='utf-8'):
return u.encode(enc)
def s2b(s, enc='utf-8'):
return s
b2s.__doc__ = "Converts bytes into a string"
u2s.__doc__ = 'Converts text into a string'
s2b.__doc__ = 'Converts a string into bytes'


class dropdict(dict):
Expand Down
4 changes: 2 additions & 2 deletions daliuge-translator/dlg/dropmake/cwl.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ def create_workflow(drops, cwl_filename):
zipBuffer = io.BytesIO()
zipObj = ZipFile(zipBuffer, 'w')
for step_file in step_files:
step_file_buffer = io.BytesIO(common.u2s(step_file["contents"]))
step_file_buffer = io.BytesIO(common.s2b(step_file["contents"]))
zipObj.writestr(step_file["filename"], step_file_buffer.getvalue())
workflow_file_buffer = io.BytesIO(common.u2s(cwl_workflow.export_string()))
workflow_file_buffer = io.BytesIO(common.s2b(cwl_workflow.export_string()))
zipObj.writestr(cwl_filename, workflow_file_buffer.getvalue())
zipObj.close()

Expand Down

0 comments on commit 218b164

Please sign in to comment.