def read_config(config, prefix):
    """Return a StrictRedis.__init__() compatible dictionary from data in the Flask config.

    Generate a dictionary compatible with StrictRedis.__init__() keyword arguments from data in the Flask
    application's configuration values relevant to Redis.

    This is where REDIS_URL (or whatever prefix used) is parsed, by calling parse_url().

    Positional arguments:
    config -- Flask application config dict.
    prefix -- Prefix used in config key names in the Flask app's configuration.

    Returns:
    Dictionary with parsed data, compatible with StrictRedis.__init__() keyword arguments.
    """
    # Get all relevant config values from Flask application.
    suffixes = ('URL', 'SOCKET', 'HOST', 'PORT', 'PASSWORD', 'DB')
    config_url, config_socket, config_host, config_port, config_password, config_db = [
        config.get('{0}_{1}'.format(prefix, suffix)) for suffix in suffixes
    ]
    result = dict()
    # Get more values from URL if provided.
    if config_url:
        result.update(parse_url(config_url))
    # Apply other config values.
    if config_socket:
        result['unix_socket_path'] = config_socket
    else:
        if config_host:
            result['host'] = config_host
        if config_port is not None:
            result['port'] = int(config_port)
    if config_password is not None:
        result['password'] = config_password
    if config_db is not None:
        result['db'] = int(config_db)
    return result
def read_config ( config , prefix ) : suffixes = ( 'URL' , 'SOCKET' , 'HOST' , 'PORT' , 'PASSWORD' , 'DB' ) config_url , config_socket , config_host , config_port , config_password , config_db = [ config . get ( '{0}_{1}' . format ( prefix , suffix ) ) for suffix in suffixes ] result = dict ( ) if config_url : result . update ( parse_url ( config_url ) ) if config_socket : result [ 'unix_socket_path' ] = config_socket else : if config_host : result [ 'host' ] = config_host if config_port is not None : result [ 'port' ] = int ( config_port ) if config_password is not None : result [ 'password' ] = config_password if config_db is not None : result [ 'db' ] = int ( config_db ) return result
Return a StrictRedis.__init__() compatible dictionary from data in the Flask config.

    Generate a dictionary compatible with StrictRedis.__init__() keyword arguments from data in the Flask
    application's configuration values relevant to Redis.

    This is where REDIS_URL (or whatever prefix used) is parsed, by calling parse_url().

    Positional arguments:
    config -- Flask application config dict.
    prefix -- Prefix used in config key names in the Flask app's configuration.

    Returns:
    Dictionary with parsed data, compatible with StrictRedis.__init__() keyword arguments.