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

Class FileBasis

source code

                object --+    
                         |    
Basics.Utilities.Utilities --+
                             |
                            FileBasis
Known Subclasses:
FileBasisBackup, SolutionFile.SolutionFile

Base class for the other OpenFOAM--file-classes

Instance Methods [hide private]
  __init__(self, name)
  openFile(self, keepContent=False, mode="r")
opens the file.
  closeFile(self)
closes the file
  readFile(self)
read the whole File into memory
  writeFile(self)
write the whole File from memory
  parse(self, cnt)
Parse a string that is to be the content, to be overriden by the sub-classes
  __str__(self)
Build a string from self.content, to be overriden by sub-classes
  makeTemp(self)
creates a temporary file
  goTo(self, l, s, out=None, echoLast=False, stop=None)
Read lines until a token is found
  goMatch(self, l, exp, out=None, stop=None)
Read lines until a regular expression is matched
  copyRest(self, l, out)
Copy the rest of the file
  purgeFile(self)
Undo all the manipulations done by PyFOAM

Inherited from Basics.Utilities.Utilities: execute, listDirectory, writeDictionaryHeader

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__


Class Variables [hide private]
  removedString = '//PyFoamRemoved: '
Comment for lines that were overwritten by PyFoam-routines
  addedString = '//PyFoamAdded'
Comment for lines that were added by PyFoam-routines

Inherited from Basics.Utilities.Utilities: excludeNames


Properties [hide private]

Inherited from object: __class__


Method Details [hide private]

__init__(self, name)
(Constructor)

source code 
Parameters:
  • name - Name of the file. If the field is zipped the .gz is appended
Overrides: Basics.Utilities.Utilities.__init__

openFile(self, keepContent=False, mode="r")

source code 
opens the file. To be overloaded by derived classes

closeFile(self)

source code 
closes the file

readFile(self)

source code 
read the whole File into memory

writeFile(self)

source code 
write the whole File from memory

parse(self, cnt)

source code 
Parse a string that is to be the content, to be overriden by the sub-classes

__str__(self)
(Informal representation operator)

source code 
Build a string from self.content, to be overriden by sub-classes
Overrides: object.__str__

makeTemp(self)

source code 
creates a temporary file

goTo(self, l, s, out=None, echoLast=False, stop=None)

source code 
Read lines until a token is found
Parameters:
  • l - a LineReader object
  • s - the string to look for
  • out - filehandle to echo the lines to
  • stop - pattern that indicates that exp will never be found (only passed through to goMatch)
  • echoLast - echo the line with the string

goMatch(self, l, exp, out=None, stop=None)

source code 
Read lines until a regular expression is matched
Parameters:
  • l - a LineReader object
  • exp - the expression to look for
  • out - filehandle to echo the lines to
  • stop - pattern that indicates that exp will never be found
Returns:
match-object if exp is found, the line if stop is found and None if the end of the file is reached

copyRest(self, l, out)

source code 
Copy the rest of the file
Parameters:
  • l - a LineReader object
  • out - filehandle to echo the lines to

purgeFile(self)

source code 

Undo all the manipulations done by PyFOAM

Goes through the file and removes all lines that were added

Class Variable Details [hide private]

removedString

Comment for lines that were overwritten by PyFoam-routines
Value:
'//PyFoamRemoved: '                                                    
      

addedString

Comment for lines that were added by PyFoam-routines
Value:
'//PyFoamAdded'