Skip to content

Commit 2c7fb97

Browse files
committed
archive name: take the filename from options
1 parent bec8f51 commit 2c7fb97

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

hepdata_converter_ws/api.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ def ping():
2222
def convert():
2323
kwargs = request.get_json(force=True)
2424
input_tar = kwargs['input']
25+
archive_name = kwargs['options'].get('filename', 'hepdata-converter-ws-data')
2526
output = StringIO.StringIO()
2627

2728
tmp_output_dir = tempfile.mkdtemp()
@@ -41,19 +42,17 @@ def convert():
4142

4243
else:
4344
pass
44-
hepdata_converter.convert(conversion_input + '/hepdata-converter-ws-data/',
45+
hepdata_converter.convert(conversion_input + '/' + archive_name + '/',
4546
conversion_output,
4647
kwargs.get('options', {}))
4748

4849
output_format = kwargs.get('options', {}).get('output_format', '')
4950

5051
if not os.path.isdir(conversion_output):
51-
arcname = 'hepdata-converter-ws-data.' + output_format
52-
else:
53-
arcname = 'hepdata-converter-ws-data'
52+
archive_name = archive_name + '.' + output_format
5453

5554
with tarfile.open(mode='w:gz', fileobj=output) as tar:
56-
tar.add(conversion_output, arcname=arcname)
55+
tar.add(conversion_output, arcname=archive_name)
5756

5857
finally:
5958
shutil.rmtree(tmp_dir, ignore_errors=True)

0 commit comments

Comments
 (0)