task: read also old autoPILOT parameter files

This commit is contained in:
Sebastian Wehling-Benatelli 2015-04-22 12:22:34 +02:00
parent 4b641f1b3c
commit 58aad840c8

View File

@ -5,7 +5,7 @@
class AutoPickParameter(object): class AutoPickParameter(object):
''' '''
AutoPickParameters is a parameter type object capable to read and/or write AutoPickParameters is a parameter type object capable to read and/or write
parameter ASCII and binary files. parameter ASCII.
:param fn str: Filename of the input file :param fn str: Filename of the input file
@ -50,6 +50,16 @@ class AutoPickParameter(object):
for line in lines: for line in lines:
parspl = line.split('\t')[:2] parspl = line.split('\t')[:2]
parFileCont[parspl[0].strip()] = parspl[1] parFileCont[parspl[0].strip()] = parspl[1]
else:
parFileCont = {}
except Exception, e:
self._printParameterError(e)
inputFile.seek(0)
lines = inputFile.readlines()
for line in lines:
if not line.startswith(('#', '%', '\n', ' ')):
parspl = line.split('#')[:2]
parFileCont[parspl[1].strip()] = parspl[0].strip()
for key, value in parFileCont.iteritems(): for key, value in parFileCont.iteritems():
try: try:
val = int(value) val = int(value)
@ -57,8 +67,8 @@ class AutoPickParameter(object):
try: try:
val = float(value) val = float(value)
except: except:
if value.find(';') > 0: if len(value.split(' ')) > 1:
vallist = value.strip().split(';') vallist = value.strip().split(' ')
val = [] val = []
for val0 in vallist: for val0 in vallist:
val0 = float(val0) val0 = float(val0)
@ -66,11 +76,6 @@ class AutoPickParameter(object):
else: else:
val = str(value.strip()) val = str(value.strip())
parFileCont[key] = val parFileCont[key] = val
else:
parFileCont = {}
except Exception, e:
self._printParameterError(e)
parFileCont = {}
self.__parameter = parFileCont self.__parameter = parFileCont
# Human-readable string representation of the object # Human-readable string representation of the object
@ -129,7 +134,7 @@ class AutoPickParameter(object):
print self print self
def _printParameterError(self, errmsg): def _printParameterError(self, errmsg):
print 'ParameterError:\n non-existent parameter %s' % errmsg print 'ParameterReadError:\n non-existent parameter %s' % errmsg
class FilterOptions(object): class FilterOptions(object):