# ICE Revision: $Id$ """Base class for pyFoam-applications Classes can also be called with a command-line string""" from optparse import OptionGroup from PyFoam.Basics.FoamOptionParser import FoamOptionParser,SubcommandFoamOptionParser from PyFoam.Error import error,warning,FatalErrorPyFoamException,PyFoamException,isatty from PyFoam.RunDictionary.SolutionDirectory import NoTouchSolutionDirectory from PyFoam.Basics.TerminalFormatter import TerminalFormatter from PyFoam import configuration format=TerminalFormatter() format.getConfigFormat("error") format.getConfigFormat("warn") import sys from os import path,getcwd,environ from copy import deepcopy from PyFoam.ThirdParty.six import print_ from PyFoam.ThirdParty.six import iteritems class PyFoamApplicationException(FatalErrorPyFoamException): def __init__(self,app,*text): self.app=app FatalErrorPyFoamException.__init__(self,*text) def __str__(self): return FatalErrorPyFoamException.__str__(self)+" in Application-class: "+self.app.__class__.__name__
import re from os import path from PyFoamApplication import PyFoamApplication from PyFoam.RunDictionary.ParsedParameterFile import ParsedParameterFile,PyFoamParserError from PyFoam.Basics.DataStructures import DictProxy,Dimension,Tensor,SymmTensor,Vector,Field,TupleProxy from PyFoam.Basics.FoamFileGenerator import makeString from PyFoam.Error import error,warning from CommonParserOptions import CommonParserOptions from PyFoam.Basics.TerminalFormatter import TerminalFormatter f=TerminalFormatter() f.getConfigFormat("source",shortName="src") f.getConfigFormat("destination",shortName="dst") f.getConfigFormat("difference",shortName="diff") f.getConfigFormat("error",shortName="name") class CompareDictionary(PyFoamApplication, CommonParserOptions): def __init__(self,args=None): description="""\ Takes two dictionary and compares them semantically (by looking at the structure, not the textual representation. If the dictionaries do not have the same name, it looks for the destination file by searching the equivalent place in the destination case. If more than two files are specified then the last name is assumed to be a directory and all the equivalents to the other files are searched there.
# ICE Revision: $Id$ """Standardized Error Messages""" import traceback import sys from PyFoam.Basics.TerminalFormatter import TerminalFormatter from PyFoam.ThirdParty.six import print_ defaultFormat=TerminalFormatter() defaultFormat.getConfigFormat("error") defaultFormat.getConfigFormat("warning",shortName="warn") def getLine(up=0): try: # just get a few frames f = traceback.extract_stack(limit=up+2) if f: return f[0] except: if __debug__: traceback.print_exc() pass return ('', 0, '', None) def isatty(s): """Workaround for outputstreams that don't implement isatty (specifically vtkPythonStdStreamCaptureHelper) """ try: return s.isatty except AttributeError:
# ICE Revision: $Id$ """Base class for pyFoam-applications Classes can also be called with a command-line string""" from optparse import OptionGroup from PyFoam.Basics.FoamOptionParser import FoamOptionParser, SubcommandFoamOptionParser from PyFoam.Error import error, warning, FatalErrorPyFoamException, PyFoamException, isatty from PyFoam.RunDictionary.SolutionDirectory import NoTouchSolutionDirectory from PyFoam.Basics.TerminalFormatter import TerminalFormatter from PyFoam import configuration format = TerminalFormatter() format.getConfigFormat("error") format.getConfigFormat("warn") import sys from os import path, getcwd, environ from copy import deepcopy from PyFoam.ThirdParty.six import print_ from PyFoam.ThirdParty.six import iteritems class PyFoamApplicationException(FatalErrorPyFoamException): def __init__(self, app, *text): self.app = app FatalErrorPyFoamException.__init__(self, *text) def __str__(self):
import re from os import path from PyFoamApplication import PyFoamApplication from PyFoam.RunDictionary.ParsedParameterFile import ParsedParameterFile from PyFoam.Basics.DataStructures import DictProxy,TupleProxy from PyFoam.Error import error,warning from CommonParserOptions import CommonParserOptions from PyFoam.Basics.TerminalFormatter import TerminalFormatter f=TerminalFormatter() f.getConfigFormat("source",shortName="src") f.getConfigFormat("destination",shortName="dst") f.getConfigFormat("difference",shortName="diff") f.getConfigFormat("question",shortName="ask") f.getConfigFormat("input") class UpdateDictionary(PyFoamApplication, CommonParserOptions): def __init__(self,args=None): description="""\ Takes two dictionary and modifies the second one after the example of the first. If the dictionaries do not have the same name, it looks for the destination file by searching the equivalent place in the destination case """
from .PyFoamApplication import PyFoamApplication from PyFoam.RunDictionary.ParsedParameterFile import ParsedParameterFile from PyFoam.Basics.DataStructures import DictProxy, TupleProxy from PyFoam.Error import error, warning from .CommonParserOptions import CommonParserOptions from PyFoam.Basics.TerminalFormatter import TerminalFormatter from PyFoam.ThirdParty.six import print_ from PyFoam.ThirdParty.six.moves import input f = TerminalFormatter() f.getConfigFormat("source", shortName="src") f.getConfigFormat("destination", shortName="dst") f.getConfigFormat("difference", shortName="diff") f.getConfigFormat("question", shortName="ask") f.getConfigFormat("input") class UpdateDictionary(PyFoamApplication, CommonParserOptions): def __init__(self, args=None, **kwargs): description = """\ Takes two dictionary and modifies the second one after the example of the first. If the dictionaries do not have the same name, it looks for the destination file by searching the equivalent place in the destination case """
from .PyFoamApplication import PyFoamApplication from PyFoam.RunDictionary.ParsedParameterFile import ParsedParameterFile,PyFoamParserError from PyFoam.Basics.DataStructures import DictProxy,Dimension,Tensor,SymmTensor,Vector,Field,TupleProxy from PyFoam.Basics.FoamFileGenerator import makeString from PyFoam.Error import error,warning from .CommonParserOptions import CommonParserOptions from PyFoam.Basics.TerminalFormatter import TerminalFormatter from PyFoam.ThirdParty.six import print_,integer_types f=TerminalFormatter() f.getConfigFormat("source",shortName="src") f.getConfigFormat("destination",shortName="dst") f.getConfigFormat("difference",shortName="diff") f.getConfigFormat("error",shortName="name") class CompareDictionary(PyFoamApplication, CommonParserOptions): def __init__(self, args=None, **kwargs): description="""\ Takes two dictionary and compares them semantically (by looking at the structure, not the textual representation. If the dictionaries do not have the same name, it looks for the destination file by searching the equivalent place in the destination case. If more than two files are