From 2095dccc085dfa60c73a65a1ae5b2c05cbffcf3f Mon Sep 17 00:00:00 2001 From: Lan Le Date: Thu, 16 May 2024 15:02:59 +0200 Subject: [PATCH] feat: storing processing time into tempfile --- chem_spectra/lib/composer/ms.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/chem_spectra/lib/composer/ms.py b/chem_spectra/lib/composer/ms.py index 7960d8d..00401ef 100644 --- a/chem_spectra/lib/composer/ms.py +++ b/chem_spectra/lib/composer/ms.py @@ -60,13 +60,22 @@ def __gen_config(self): def __gen_ms_spectra(self): msspcs = [] + ms_tempfile = tempfile.TemporaryFile() for idx, dt in enumerate(self.core.datatables): msspc = [ '##PAGE={}\n'.format(idx + 1), '##NPOINTS={}\n'.format(dt['pts']), TEXT_MS_DATA_TABLE, ] - msspcs = msspcs + msspc + dt['dt'] + my_content = msspc + dt['dt'] + file_content = ''.join(my_content) + ms_tempfile.write(file_content.encode('utf-8')) + + ms_tempfile.seek(0) + lines = ms_tempfile.readlines() + decoded_lines = [line.decode('utf-8').strip() for line in lines] + msspcs = '\n'.join(decoded_lines) + ms_tempfile.close() return msspcs def __compose(self):