From ffcb6ef2c4a6dc0f87449d674cf5ea513d831695 Mon Sep 17 00:00:00 2001 From: geay Date: Tue, 25 Mar 2014 11:28:52 +0100 Subject: [PATCH] Bug CEA#1110 with case files having no fields --- src/MEDLoader/Swig/CaseReader.py | 58 +++++++++++++++++--------------- 1 file changed, 30 insertions(+), 28 deletions(-) diff --git a/src/MEDLoader/Swig/CaseReader.py b/src/MEDLoader/Swig/CaseReader.py index 4fc96fc42..18adfe2c5 100644 --- a/src/MEDLoader/Swig/CaseReader.py +++ b/src/MEDLoader/Swig/CaseReader.py @@ -357,36 +357,38 @@ class CaseReader(CaseIO): raise Exception("Error with file %s"%(fname)) geoName=re.match("model:([\W]*)([\w\.]+)",lines[ind+1]).group(2) m1,m2,typeOfFile=self.__convertGeo2MED(geoName) - fieldsInfo=[] - ind=lines.index("VARIABLE\n") - end=len(lines)-1 - if "TIME\n" in lines: - end=lines.index("TIME\n") - pass - for i in xrange(ind+1,end): - m=re.match("^([\w]+)[\s]+\per[\s]+([\w]+)[\s]*\:[\s]*([\w]+)[\s]+([\S]+)$",lines[i]) - if m: - if m.groups()[0]=="constant": - continue - spatialDisc=m.groups()[1] ; fieldName=m.groups()[2] ; nbOfCompo=self.dictCompo2[m.groups()[0]] ; fieldFileName=m.groups()[3] - fieldsInfo.append((fieldName,spatialDisc,nbOfCompo,fieldFileName)) + fieldsInfo=[] ; nbOfTimeSteps=0 + if "VARIABLE\n" in lines: + ind=lines.index("VARIABLE\n") + end=len(lines)-1 + if "TIME\n" in lines: + end=lines.index("TIME\n") pass + for i in xrange(ind+1,end): + m=re.match("^([\w]+)[\s]+\per[\s]+([\w]+)[\s]*\:[\s]*([\w]+)[\s]+([\S]+)$",lines[i]) + if m: + if m.groups()[0]=="constant": + continue + spatialDisc=m.groups()[1] ; fieldName=m.groups()[2] ; nbOfCompo=self.dictCompo2[m.groups()[0]] ; fieldFileName=m.groups()[3] + fieldsInfo.append((fieldName,spatialDisc,nbOfCompo,fieldFileName)) + pass + pass + + expr=re.compile("number[\s]+of[\s]+steps[\s]*\:[\s]*([\d]+)") + tmp=filter(expr.search,lines) + if len(tmp)!=0: + nbOfTimeSteps=int(expr.search(filter(expr.search,lines)[0]).group(1)) + expr=re.compile("filename[\s]+start[\s]+number[\s]*\:[\s]*([\d]+)") + startIt=int(expr.search(filter(expr.search,lines)[0]).group(1)) + expr=re.compile("filename[\s]+increment[\s]*\:[\s]*([\d]+)") + incrIt=int(expr.search(filter(expr.search,lines)[0]).group(1)) + else: + nbOfTimeSteps=1 + startIt=0 + incrIt=1 + pass + curIt=startIt pass - - expr=re.compile("number[\s]+of[\s]+steps[\s]*\:[\s]*([\d]+)") - tmp=filter(expr.search,lines) - if len(tmp)!=0: - nbOfTimeSteps=int(expr.search(filter(expr.search,lines)[0]).group(1)) - expr=re.compile("filename[\s]+start[\s]+number[\s]*\:[\s]*([\d]+)") - startIt=int(expr.search(filter(expr.search,lines)[0]).group(1)) - expr=re.compile("filename[\s]+increment[\s]*\:[\s]*([\d]+)") - incrIt=int(expr.search(filter(expr.search,lines)[0]).group(1)) - else: - nbOfTimeSteps=1 - startIt=0 - incrIt=1 - pass - curIt=startIt mlfields=MEDFileFields() mlfields.resize(len(fieldsInfo)*len(m1)) i=0 -- 2.39.2