Skip to content

Commit

Permalink
Merge pull request #15 from HEPData/fix-tarfile-mode
Browse files Browse the repository at this point in the history
Ensure we pass the file mode to tarfile.open instead of a name
  • Loading branch information
GraemeWatt authored Mar 1, 2021
2 parents 144e8d4 + 379d6fd commit fdff580
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions hepdata_converter_ws_client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def convert(url, input, output=None, options={}, id=None, extract=True, timeout=

error_occurred = False
try:
tarfile.open('r:gz', fileobj=BytesIO(r.content)).close()
tarfile.open(mode='r:gz', fileobj=BytesIO(r.content)).close()
except tarfile.ReadError:
error_occurred = True

Expand All @@ -103,7 +103,7 @@ def convert(url, input, output=None, options={}, id=None, extract=True, timeout=

tmp_dir = tempfile.mkdtemp(suffix='hdc')
try:
with tarfile.open('r:gz', fileobj=BytesIO(r.content)) as tar:
with tarfile.open(mode='r:gz', fileobj=BytesIO(r.content)) as tar:
tar.extractall(tmp_dir)
content = os.listdir(tmp_dir)[0]
shutil.move(os.path.join(tmp_dir, content), output)
Expand Down

0 comments on commit fdff580

Please sign in to comment.