PyFoam.Applications.PyFoamApplication module

Base class for pyFoam-applications

Classes can also be called with a command-line string

class PyFoam.Applications.PyFoamApplication.PyFoamApplication(args=None, description=None, epilog=None, examples=None, usage=None, interspersed=False, nr=None, changeVersion=True, exactNr=True, subcommands=None, inputApp=None, localConfigurationFile=None, findLocalConfigurationFile=None, allowCurses=True, **kwArgs)[source]

Bases: object

This class is the base for all pyFoam-utilities

CWindowType

alias of PyFoam.Applications.CursesApplicationWrapper.CWindow

__dict__ = mappingproxy({'__module__': 'PyFoam.Applications.PyFoamApplication', '__doc__': 'This class is the base for all pyFoam-utilities', 'iDict': <class 'PyFoam.Applications.PyFoamApplication.PyFoamApplication.iDict'>, 'CWindowType': <class 'PyFoam.Applications.CursesApplicationWrapper.CWindow'>, '__init__': <function PyFoamApplication.__init__>, '__getitem__': <function PyFoamApplication.__getitem__>, '__setitem__': <function PyFoamApplication.__setitem__>, '__iter__': <function PyFoamApplication.__iter__>, 'iterkeys': <function PyFoamApplication.iterkeys>, 'iteritems': <function PyFoamApplication.iteritems>, '__getattr__': <function PyFoamApplication.__getattr__>, 'getData': <function PyFoamApplication.getData>, 'setData': <function PyFoamApplication.setData>, 'ensureGeneralOptions': <function PyFoamApplication.ensureGeneralOptions>, 'addOptions': <function PyFoamApplication.addOptions>, 'run': <function PyFoamApplication.run>, 'error': <function PyFoamApplication.error>, 'errorPrint': <function PyFoamApplication.errorPrint>, 'warning': <function PyFoamApplication.warning>, 'depreciationWarning': <function PyFoamApplication.depreciationWarning>, 'silent': <function PyFoamApplication.silent>, 'checkCase': <function PyFoamApplication.checkCase>, 'escapeArgument': <function PyFoamApplication.escapeArgument>, 'addToCaseLog': <function PyFoamApplication.addToCaseLog>, 'addLocalConfig': <function PyFoamApplication.addLocalConfig>, 'getCasePath': <function PyFoamApplication.getCasePath>, 'replaceAutoInArgs': <function PyFoamApplication.replaceAutoInArgs>, 'getApplication': <function PyFoamApplication.getApplication>, 'localConfigFromCasename': <function PyFoamApplication.localConfigFromCasename>, 'localConfigInArgs': <function PyFoamApplication.localConfigInArgs>, 'localConfigInArgsFile': <function PyFoamApplication.localConfigInArgsFile>, 'localConfigInCWD': <function PyFoamApplication.localConfigInCWD>, '__dict__': <attribute '__dict__' of 'PyFoamApplication' objects>, '__weakref__': <attribute '__weakref__' of 'PyFoamApplication' objects>})
__getattr__(key)[source]
__getitem__(key)[source]

Get application data

__init__(args=None, description=None, epilog=None, examples=None, usage=None, interspersed=False, nr=None, changeVersion=True, exactNr=True, subcommands=None, inputApp=None, localConfigurationFile=None, findLocalConfigurationFile=None, allowCurses=True, **kwArgs)[source]
Parameters
  • description – description of the command

  • epilog – text to be printed after the options-help

  • examples – usage examples to be printed after the epilog

  • usage – Usage

  • interspersed – Is the command line allowed to be interspersed (options after the arguments)

  • args – Command line arguments when using the Application as a ‘class’ from a script

  • nr – Number of required arguments

  • changeVersion – May this application change the version of OF used?

  • exactNr – Must not have more than the required number of arguments

  • subcommands – parse and use subcommands from the command line. Either True or a list with subcommands

  • inputApp – Application with input data. Used to allow a ‘pipe-like’ behaviour if the class is used from a Script

  • localConfigurationFile – Use this file (or list of files) as a local configuration

  • findLocalConfigurationFile – Method to find a configuration file BEFORE the actual parameters are parsed

  • allowCurses – This application can wrap the output in a curses-window

__iter__()[source]

Iterate over the application data

__module__ = 'PyFoam.Applications.PyFoamApplication'
__setitem__(key, value)[source]

Set data. Only if key does not exist (data can only be set once)

__weakref__

list of weak references to the object (if defined)

addLocalConfig(directory=None)[source]

Adds a local directory (assuming it is found)

addOptions()[source]

Add options to the parser

addToCaseLog(name, *text)[source]

Add information about the application that was run to the case-log

checkCase(name, fatal=True, verbose=True)[source]

Check whether this is a valid OpenFOAM-case :param name: the directory-bame that is supposed to be the case :param fatal: If this is not a case then the application ends :param verbose: If this is not a case no warning is issued

depreciationWarning(reason)[source]
ensureGeneralOptions()[source]
error(*args)[source]

Raise a error exception. How it will be handled is a different story :param args: Arguments to the exception

errorPrint(*args)[source]

Prints an error message and exits :param args: Arguments that are to be printed

escapeArgument(arg)[source]

Check if this argument has spaces etc and surround it with ” to make it copypastable

getApplication()[source]
getCasePath(args)[source]

Try to determine the actual case location from the arguments

getData()[source]

Get the application data

class iDict[source]

Bases: dict

This class is a quick and dirty wrapper to use a dictionary like a struct

__dict__ = mappingproxy({'__module__': 'PyFoam.Applications.PyFoamApplication', '__doc__': 'This class is a quick and dirty wrapper to use a dictionary like a struct', '__getattr__': <function PyFoamApplication.iDict.__getattr__>, '__dict__': <attribute '__dict__' of 'iDict' objects>, '__weakref__': <attribute '__weakref__' of 'iDict' objects>})
__getattr__(key)[source]
__module__ = 'PyFoam.Applications.PyFoamApplication'
__weakref__

list of weak references to the object (if defined)

iteritems()[source]
iterkeys()[source]
localConfigFromCasename(args)[source]

Look for the local configuration assuming that the first argument after ‘-case’ is the case directory

localConfigInArgs(args)[source]

Assume that the first argument that is no option and a directory can have a local configuration

localConfigInArgsFile(args)[source]

Assume that the first argument that is no option and a file can has a local configuration in the same directory

localConfigInCWD(args)[source]

find the local configuration in the current directory

replaceAutoInArgs(args)[source]

If the first argument is ‘auto’ replace it with the ‘application’ entry from the controlDict

run()[source]

Run the real application

setData(data)[source]

Set the application data

Parameters

data – dictionary whose entries will be added to the

application data (possibly overwriting old entries of the same name)

silent(*args)[source]

Don’t print a warning message :param args: Arguments that are to be printed

warning(*args)[source]

Prints a warning message :param args: Arguments that are to be printed

exception PyFoam.Applications.PyFoamApplication.PyFoamApplicationException(app, *text)[source]

Bases: PyFoam.Error.FatalErrorPyFoamException

__init__(app, *text)[source]

Initialize self. See help(type(self)) for accurate signature.

__module__ = 'PyFoam.Applications.PyFoamApplication'
__str__()[source]

Return str(self).

PyFoam.Applications.PyFoamApplication.pyFoamExceptionHook(type, value, tb, debugOnSyntaxError=False)[source]
PyFoam.Applications.PyFoamApplication.pyFoamSIG1HandlerPrintStack(nr, frame)[source]