コード例 #1
0
ファイル: conf.py プロジェクト: olivierverdier/sfepy
    def from_file(filename, required=None, other=None, verbose=True,
                  define_args=None):
        """
        Loads the problem definition from a file.

        The filename can either contain plain definitions, or it can contain
        the define() function, in which case it will be called to return the
        input definitions.

        The job of the define() function is to return a dictionary of
        parameters. How the dictionary is constructed is not our business, but
        the usual way is to simply have a function define() along these lines
        in the input file:

            def define():
                options = {
                    'save_eig_vectors' : None,
                    'eigen_solver' : 'eigen1',
                }
                region_2 = {
                    'name' : 'Surface',
                    'select' : 'nodes of surface',
                }
                return locals()

        Optionally, the define() function can accept keyword arguments
        that should be defined using the `define_args` dictionary.
        """
        funmod = import_file( filename )


        if "define" in funmod.__dict__:
            if define_args is None:
                define_dict = funmod.__dict__["define"]()

            else:
                define_dict = funmod.__dict__["define"](**define_args)

        else:
            define_dict = funmod.__dict__

        obj = ProblemConf(define_dict, funmod, filename,
                          required, other, verbose)

        return obj
コード例 #2
0
ファイル: conf.py プロジェクト: certik/sfepy
    def from_file( filename, required = None, other = None ):
        """
        Loads the problem definition from a file.

        The filename can either contain plain definitions, or it can contain
        the define() function, in which case it will be called to return the
        input definitions.

        The job of the define() function is to return a dictionary of
        parameters. How the dictionary is constructed is not our business, but
        the usual way is to simply have a function define() along these lines
        in the input file:

            def define():
                options = {
                    'save_eig_vectors' : None,
                    'eigen_solver' : 'eigen1',
                }
                region_2 = {
                    'name' : 'Surface',
                    'select' : 'nodes of surface',
                }
                ...
                return locals()

        """
        funmod = import_file( filename )
        obj = ProblemConf()
        if "define" in funmod.__dict__:
            define_dict = funmod.__dict__["define"]()
        else:
            define_dict = funmod.__dict__

        obj.__dict__.update( define_dict )

        obj.setup( define_dict, funmod, filename, required, other )

        return obj