]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
Bug CEA#1110 with case files having no fields
authorgeay <anthony.geay@cea.fr>
Tue, 25 Mar 2014 10:28:52 +0000 (11:28 +0100)
committergeay <anthony.geay@cea.fr>
Tue, 25 Mar 2014 10:28:52 +0000 (11:28 +0100)
src/MEDLoader/Swig/CaseReader.py

index 4fc96fc42ad66bb5354d0e6fb89fbd90699e5ac9..18adfe2c5b12b5c4ef4d9ddbdd896c7a0b2ae906 100644 (file)
@@ -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