示例#1
0
def valid_gsl_dir(val):
    """
    Validate given string to be path containing required GSL files.
    """
    if val is None:
        return True
    if not isinstance(val, str):
        raise PreferenceError(f'Illegal value for GSL directory: {str(val)}, has to be str')
    if not os.path.isdir(val):
        raise PreferenceError(f'Illegal value for GSL directory: {val}, has to be existing directory')
    if any(not os.path.isfile(os.path.join(val, 'gsl', filename))
           for filename in ['gsl_odeiv2.h', 'gsl_errno.h', 'gsl_matrix.h']):
        raise PreferenceError(f"Illegal value for GSL directory: '{val}', "
                               f"has to contain gsl_odeiv2.h, gsl_errno.h "
                               f"and gsl_matrix.h")
    return True
示例#2
0
def valid_gsl_dir(val):
    '''
    Validate given string to be path containing required GSL files.
    '''
    if val is None:
        return True
    if not isinstance(val, basestring):
        raise PreferenceError(('Illegal value for GSL directory: %s, '
                               'has to be str' % (str(val))))
    if not os.path.isdir(val):
        raise PreferenceError(('Illegal value for GSL directory: %s, '
                               'has to be existing directory' % (val)))
    if any(not os.path.isfile(os.path.join(val, 'gsl', filename))
           for filename in ['gsl_odeiv2.h', 'gsl_errno.h', 'gsl_matrix.h']):
        raise PreferenceError(('Illegal value for GSL directory: %s, '
                               'has to contain gsl_odeiv2.h, gsl_errno.h '
                               'and gsl_matrix.h' % (val)))
    return True