From: <zk...@us...> - 2009-01-20 12:59:40
|
Revision: 600 http://pyphant.svn.sourceforge.net/pyphant/?rev=600&view=rev Author: zklaus Date: 2009-01-20 12:59:31 +0000 (Tue, 20 Jan 2009) Log Message: ----------- Bugfix in FMFLoader: Corrected interpretation of scalars and negative quantities. Modified Paths: -------------- trunk/src/workers/fmfile/fmfile/FMFLoader.py Modified: trunk/src/workers/fmfile/fmfile/FMFLoader.py =================================================================== --- trunk/src/workers/fmfile/fmfile/FMFLoader.py 2009-01-20 12:51:30 UTC (rev 599) +++ trunk/src/workers/fmfile/fmfile/FMFLoader.py 2009-01-20 12:59:31 UTC (rev 600) @@ -235,7 +235,7 @@ \s*:\s* # divider (.*) # value (including list values and comments) $ # line end - ''', re.VERBOSE) + ''', re.VERBOSE) from StringIO import StringIO config = FMFConfigObj(d.encode('utf-8').splitlines(), encoding='utf-8') return config2tables(preParsedData, config) @@ -250,7 +250,7 @@ unit = float(unit[:-4]) except: unit = 1.0 - elif not unit[0].isdigit(): + elif not (unit[0].isdigit() or unit[0]=='-'): unit = '1'+unit try: unit = unit.replace('^', '**') @@ -277,7 +277,7 @@ unit = str2unit(unit) value *= unit else: - value = str2unit(value) + value = str2unit(value) if error != None: if error.endswith('%'): error = value*float(error[:-1])/100.0 @@ -295,14 +295,15 @@ return False raise AttributeError - converters = [ parseVariable, - parseQuantity, - int, - float, - complex, - parseBool, - lambda d: str(mx.DateTime.ISO.ParseAny(d)) - ] + converters = [ + int, + float, + complex, + parseBool, + parseQuantity, + parseVariable, + lambda d: str(mx.DateTime.ISO.ParseAny(d)) + ] def item2value(section, key): oldVal = section[key] @@ -332,8 +333,8 @@ else: shortname = k.split(':')[1].strip() tables.append(data2table(longnames[shortname], - shortname, - preParsedData[shortname], + shortname, + preParsedData[shortname], config[k])) del config[k] attributes = config.walk(item2value) @@ -415,7 +416,7 @@ if localVar[key.strip()]=='whitespace': localVar[key.strip()] = None if localVar[key.strip()]=='semicolon': - localVar[key.strip()] = ';' + localVar[key.strip()] = ';' d = unicode(b, localVar['coding']) dataExpr = re.compile(ur"^(\[\*data(?::\s*([^\]]*))?\]\r?\n)([^[]*)", re.MULTILINE | re.DOTALL) commentExpr = re.compile(ur"^%s.*"%commentChar, re.MULTILINE) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |