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

Class FileBasis

Utilities --+
            |
           FileBasis

Known Subclasses:
FileBasisBackup, SolutionFile

Base class for the other OpenFOAM--file-classes
Method Summary
  __init__(self, name)
name - Name of the file
  closeFile(self)
closes the file
  copyRest(self, l, out)
Copy the rest of the file
  goMatch(self, l, exp, out, stop)
Read lines until a regular expression is matched
  goTo(self, l, s, out, echoLast, stop)
Read lines until a token is found
  makeString(self)
Build a string from self.content, to be overriden by sub-classes
  makeTemp(self)
creates a temporary file
  openFile(self, keepContent, mode)
opens the file.
  parse(self, cnt)
Parse a string that is to be the content, to be overriden by the sub-classes
  purgeFile(self)
Undo all the manipulations done by PyFOAM
  readFile(self)
read the whole File into memory
  writeFile(self)
write the whole File from memory
    Inherited from Utilities
  execute(self, cmd, debug)
Execute the command cmd
  listDirectory(self, d)
Lists the files in a directory, but excludes certain names and files with certain endings
  writeDictionaryHeader(self, f)
Writes a dummy header so OpenFOAM accepts the file as a dictionary

Class Variable Summary
str addedString = '//PyFoamAdded'
str removedString = '//PyFoamRemoved: '
    Inherited from Utilities
list excludeNames = ['^.svn$', '~$']

Method Details

__init__(self, name)
(Constructor)

name - Name of the file
Overrides:
PyFoam.Basics.Utilities.Utilities.__init__

closeFile(self)

closes the file

copyRest(self, l, out)

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

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

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

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

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
echoLast - echo the line with the string
stop - pattern that indicates that exp will never be found (only passed through to goMatch)

makeString(self)

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

makeTemp(self)

creates a temporary file

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

opens the file. To be overloaded by derived classes

parse(self, cnt)

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

purgeFile(self)

Undo all the manipulations done by PyFOAM

Goes through the file and removes all lines that were added

readFile(self)

read the whole File into memory

writeFile(self)

write the whole File from memory

Class Variable Details

addedString

Type:
str
Value:
'//PyFoamAdded'                                                        

removedString

Type:
str
Value:
'//PyFoamRemoved: '                                                    

Generated by Epydoc 2.1 on Mon Jan 22 23:52:48 2007 http://epydoc.sf.net