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

Class FileBasis

source code

                object --+    
                         |    
Basics.Utilities.Utilities --+
                             |
                            FileBasis

Base class for the other OpenFOAM--file-classes

Instance Methods [hide private]
 
__init__(self, name, createZipped=True)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
source code
 
realName(self)
The full filename with appended .gz (if zipped)
source code
 
baseName(self)
Returns the basic file name (without .gz)
source code
 
openFile(self, keepContent=False, mode="r")
opens the file.
source code
 
closeFile(self)
closes the file
source code
 
readFile(self)
read the whole File into memory
source code
 
writeFile(self, content=None)
write the whole File from memory
source code
 
writeFileAs(self, name)
Writes a copy of the file.
source code
 
parse(self, cnt)
Parse a string that is to be the content, to be overriden by the sub-classes
source code
 
__str__(self)
Build a string from self.content, to be overriden by sub-classes
source code
 
makeTemp(self)
creates a temporary file
source code
 
goTo(self, l, s, out=None, echoLast=False, stop=None)
Read lines until a token is found
source code
 
goMatch(self, l, exp, out=None, stop=None)
Read lines until a regular expression is matched
source code
 
copyRest(self, l, out)
Copy the rest of the file
source code
 
purgeFile(self)
Undo all the manipulations done by PyFOAM
source code
 
getCaseDir(self)
Return the path to the case of this file (if any valid case is found).
source code

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, createZipped=True)
(Constructor)

source code 

x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Parameters:
  • name - Name of the file. If the field is zipped the .gz is appended
  • createZipped - if the file doesnot exist: should it be created as a zipped file?
Overrides: object.__init__

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

source code 

opens the file. To be overloaded by derived classes

writeFile(self, content=None)

source code 

write the whole File from memory

Parameters:
  • content - content that should replace the old content

writeFileAs(self, name)

source code 

Writes a copy of the file. Extends with .gz if the original is zipped

Parameters:
  • name - Name under which the file is written

__str__(self)
(Informal representation operator)

source code 

Build a string from self.content, to be overriden by sub-classes

Overrides: object.__str__

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

getCaseDir(self)

source code 

Return the path to the case of this file (if any valid case is found). Else return None