(config_filename, environment)
Reads a configuration file from the given path and configures the
    given environment accordingly.
Reads a configuration file from the given path and configures the
    given environment accordingly.
Reads a configuration file from the given path and configures the given environment accordingly .
def configure_environment(config_filename, environment):
    """
    Reads a configuration file from the given path and configures the
    given environment accordingly.
    """
    factory = environment.factory

    if not os.path.exists(config_filename):
        raise PysmtIOError("File '%s' does not exists." % config_filename)

    # We do not use variable inside the config file
    config = cp.RawConfigParser()
    config.read(config_filename)

    new_solvers_sections = [s for s in config.sections()
                            if s.lower().startswith("smtlibsolver ")]

    for s in new_solvers_sections:
        name = s[len("smtlibsolver "):]

        cmd = config.get(s, "command")
        assert cmd is not None, ("Missing 'command' value in definition"
                                 "of '%s' solver" % name)

        logics_string = config.get(s, "logics")
        if logics_string is None:
            warn("Missing 'logics' value in definition of '%s' solver" % name,
                 stacklevel=2)
            continue

        logics = [get_logic_by_name(l) for l in logics_string.split()]

        factory.add_generic_solver(name, cmd.split(), logics)


    if "global" in config.sections():
        infix = config.get("global", "use_infix_notation")
        pref_list = config.get("global", "solver_preference_list")
        if infix is not None:
            if infix.lower() == "true":
                environment.enable_infix_notation = True
            elif infix.lower() == "false":
                environment.enable_infix_notation = True
            else:
                warn("Unknown value for 'use_infix_notation': %s" % infix,
                     stacklevel=2)

        if pref_list is not None:
            prefs = pref_list.split()
            for s in prefs:
                if s not in factory.all_solvers():
                    warn("Unknown solver '%s' in solver_preference_list" % s,
                         stacklevel=2)

            for s in factory.all_solvers():
                if s not in prefs:
                    warn("Solver '%s' is not in the preference list, "\
                         "and will be disabled." % s,
                         stacklevel=2)

            factory.set_solver_preference_list(prefs)
def configure_environment ( config_filename , environment ) : factory = environment . factory if not os . path . exists ( config_filename ) : raise PysmtIOError ( "File '%s' does not exists." % config_filename ) # We do not use variable inside the config file config = cp . RawConfigParser ( ) config . read ( config_filename ) new_solvers_sections = [ s for s in config . sections ( ) if s . lower ( ) . startswith ( "smtlibsolver " ) ] for s in new_solvers_sections : name = s [ len ( "smtlibsolver " ) : ] cmd = config . get ( s , "command" ) assert cmd is not None , ( "Missing 'command' value in definition" "of '%s' solver" % name ) logics_string = config . get ( s , "logics" ) if logics_string is None : warn ( "Missing 'logics' value in definition of '%s' solver" % name , stacklevel = 2 ) continue logics = [ get_logic_by_name ( l ) for l in logics_string . split ( ) ] factory . add_generic_solver ( name , cmd . split ( ) , logics ) if "global" in config . sections ( ) : infix = config . get ( "global" , "use_infix_notation" ) pref_list = config . get ( "global" , "solver_preference_list" ) if infix is not None : if infix . lower ( ) == "true" : environment . enable_infix_notation = True elif infix . lower ( ) == "false" : environment . enable_infix_notation = True else : warn ( "Unknown value for 'use_infix_notation': %s" % infix , stacklevel = 2 ) if pref_list is not None : prefs = pref_list . split ( ) for s in prefs : if s not in factory . all_solvers ( ) : warn ( "Unknown solver '%s' in solver_preference_list" % s , stacklevel = 2 ) for s in factory . all_solvers ( ) : if s not in prefs : warn ( "Solver '%s' is not in the preference list, " "and will be disabled." % s , stacklevel = 2 ) factory . set_solver_preference_list ( prefs )