Example #1
0
def get_logging_conf(conf, log_name='log'):
    """
    Check for a log configuration ('log' attribute by default) in
    `conf`. Supply default values if necessary.

    Parameters
    ----------
    conf : Struct
        The configuration object.
    log_name : str, optional
        The name of the log configuration attribute in `conf`.

    Returns
    -------
    log : dict
        The dictionary {'plot' : <figure_file>, 'text' : <text_log_file>}. One
        or both values can be None.
    """
    log = conf.get(log_name, None)

    default_log = {'text' : None, 'plot' : None}

    if log is None:
        log = default_log

    else:
        set_defaults(log, default_log)

    return log
Example #2
0
File: log.py Project: Gkdnz/sfepy
def get_logging_conf(conf, log_name='log'):
    """
    Check for a log configuration ('log' attribute by default) in
    `conf`. Supply default values if necessary.

    Parameters
    ----------
    conf : Struct
        The configuration object.
    log_name : str, optional
        The name of the log configuration attribute in `conf`.

    Returns
    -------
    log : dict
        The dictionary {'plot' : <figure_file>, 'text' : <text_log_file>}. One
        or both values can be None.
    """
    log = conf.get(log_name, None)

    default_log = {'text' : None, 'plot' : None}

    if log is None:
        log = default_log

    else:
        set_defaults(log, default_log)

    return log
Example #3
0
def try_set_defaults( obj, attr, defaults ):
    try:
        values = getattr( obj, attr )
        set_defaults( values, defaults )
    except:
        values = defaults
    return values
Example #4
0
def try_set_defaults(obj, attr, defaults, recur=False):
    try:
        values = getattr(obj, attr)

    except:
        values = defaults

    else:
        if recur and isinstance(values, dict):
            for key, val in values.iteritems():
                set_defaults(val, defaults)

        else:
            set_defaults(values, defaults)

    return values
Example #5
0
def get_logging_conf(conf):
    """
    Check for a logging configuration ('log' attribute) in conf. Supply default
    values if necessary.
    
    Returns
    -------
    log : dict
        The dictionary {'plot' : <figure_file>, 'text' : <text_log_file>}. One
        or both values can be None.
    """
    get = conf.get_default_attr

    log = get('log', None)

    default_log = {'text' : None, 'plot' : None}

    if log is None:
        log = default_log

    else:
        set_defaults(log, default_log)

    return log
Example #6
0
File: log.py Project: sdurve/sfepy
def get_logging_conf(conf):
    """
    Check for a logging configuration ('log' attribute) in conf. Supply default
    values if necessary.
    
    Returns
    -------
    log : dict
        The dictionary {'plot' : <figure_file>, 'text' : <text_log_file>}. One
        or both values can be None.
    """
    get = conf.get_default_attr

    log = get('log', None)

    default_log = {'text': None, 'plot': None}

    if log is None:
        log = default_log

    else:
        set_defaults(log, default_log)

    return log