task: read also old autoPILOT parameter files
This commit is contained in:
parent
4b641f1b3c
commit
58aad840c8
@ -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,27 +50,32 @@ 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]
|
||||||
for key, value in parFileCont.iteritems():
|
|
||||||
try:
|
|
||||||
val = int(value)
|
|
||||||
except:
|
|
||||||
try:
|
|
||||||
val = float(value)
|
|
||||||
except:
|
|
||||||
if value.find(';') > 0:
|
|
||||||
vallist = value.strip().split(';')
|
|
||||||
val = []
|
|
||||||
for val0 in vallist:
|
|
||||||
val0 = float(val0)
|
|
||||||
val.append(val0)
|
|
||||||
else:
|
|
||||||
val = str(value.strip())
|
|
||||||
parFileCont[key] = val
|
|
||||||
else:
|
else:
|
||||||
parFileCont = {}
|
parFileCont = {}
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
self._printParameterError(e)
|
self._printParameterError(e)
|
||||||
parFileCont = {}
|
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():
|
||||||
|
try:
|
||||||
|
val = int(value)
|
||||||
|
except:
|
||||||
|
try:
|
||||||
|
val = float(value)
|
||||||
|
except:
|
||||||
|
if len(value.split(' ')) > 1:
|
||||||
|
vallist = value.strip().split(' ')
|
||||||
|
val = []
|
||||||
|
for val0 in vallist:
|
||||||
|
val0 = float(val0)
|
||||||
|
val.append(val0)
|
||||||
|
else:
|
||||||
|
val = str(value.strip())
|
||||||
|
parFileCont[key] = val
|
||||||
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):
|
||||||
|
Loading…
Reference in New Issue
Block a user