Package PyFoam :: Package RunDictionary :: Module ListFile
[hide private]
[frames] | no frames]

Source Code for Module PyFoam.RunDictionary.ListFile

 1  #  ICE Revision: $Id$ 
 2  """File that contains only a list (for instance points)""" 
 3   
 4  from PyFoam.Basics.LineReader import LineReader 
 5  from PyFoam.RunDictionary.SolutionFile import SolutionFile 
 6   
 7  from PyFoam.ThirdParty.six import PY3 
 8   
 9  if PY3: 
10      long=int 
11   
12 -class ListFile(SolutionFile):
13 """Represents a OpenFOAM file with only a list""" 14
15 - def __init__(self,place,name):
16 """@param place: directory of the file 17 @param name: The name of the list file""" 18 19 SolutionFile.__init__(self,place,name)
20
21 - def getSize(self):
22 """@return: the size of the list""" 23 24 size=-1 # should be long 25 26 l=LineReader() 27 self.openFile() 28 29 while l.read(self.fh): 30 try: 31 size=long(l.line) 32 break 33 except ValueError: 34 pass 35 36 self.closeFile() 37 38 return size
39 40 # Should work with Python3 and Python2 41