From 4a00f518855d5181279b4347f22aaa4983ce0056 Mon Sep 17 00:00:00 2001 From: Gregory Ashton <gregory.ashton@ligo.org> Date: Thu, 22 Mar 2018 17:04:29 +1100 Subject: [PATCH] Update read_par to take strings as values --- pyfstat/core.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/pyfstat/core.py b/pyfstat/core.py index e781c88..3b9fb75 100755 --- a/pyfstat/core.py +++ b/pyfstat/core.py @@ -120,10 +120,14 @@ def _get_dictionary_from_lines(lines, comments, raise_error): try: key, val = line.rstrip('\n').split('=') key = key.strip() - try: - d[key] = np.float64(eval(val.rstrip('; '))) - except NameError: - d[key] = val.rstrip('; ') + val = val.strip() + if (val[0] in ["'", '"']) and (val[-1] in ["'", '"']): + d[key] = val.lstrip('"').lstrip("'").rstrip('"').rstrip("'") + else: + try: + d[key] = np.float64(eval(val.rstrip('; '))) + except NameError: + d[key] = val.rstrip('; ') except SyntaxError: if raise_error: raise IOError('Line {} not understood'.format(line)) -- GitLab