Skip to content

Commit 8da9f40

Browse files
jochenklarphuang26
authored andcommitted
Add support for user given conversion formats
1 parent 97f2db3 commit 8da9f40

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

converter_app/app.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from .options import OPTIONS
1515
from .readers import registry
1616
from .utils import checkpw, human2bytes
17+
from .writers.jcamp import JcampWriter
1718
from .writers.jcampzip import JcampZipWriter
1819

1920

@@ -104,7 +105,17 @@ def retrieve_conversion():
104105
converter.process()
105106

106107
if converter.tables:
107-
writer = JcampZipWriter(converter)
108+
conversion_format = request.form.get('format', 'jcampzip')
109+
110+
if conversion_format == 'jcampzip':
111+
writer = JcampZipWriter(converter)
112+
elif conversion_format == 'jcamp':
113+
if len(converter.tables) == 1:
114+
writer = JcampWriter(converter)
115+
else:
116+
return jsonify({'error': 'Conversion to a single JCAMP file is not supported for this file.'}), 400
117+
else:
118+
return jsonify({'error': 'Conversion format is not supported.'}), 400
108119
else:
109120
return jsonify({'error': 'No tables could be converted.'}), 400
110121

0 commit comments

Comments
 (0)