def generate_base(model, model_dict, config, manifest, source_config,
                  provider, adapter=None):
    """Generate the common aspects of the config dict."""
    if provider is None:
        raise dbt.exceptions.InternalException(
            "Invalid provider given to context: {}".format(provider))

    target_name = config.target_name
    target = config.to_profile_info()
    del target['credentials']
    target.update(config.credentials.serialize(with_aliases=True))
    target['type'] = config.credentials.type
    target.pop('pass', None)
    target['name'] = target_name

    adapter = get_adapter(config)

    context = {'env': target}

    pre_hooks = None
    post_hooks = None

    db_wrapper = DatabaseWrapper(adapter)

    context = dbt.utils.merge(context, {
        "adapter": db_wrapper,
        "api": {
            "Relation": db_wrapper.Relation,
            "Column": adapter.Column,
        },
        "column": adapter.Column,
        "config": provider.Config(model_dict, source_config),
        "database": config.credentials.database,
        "env_var": env_var,
        "exceptions": dbt.exceptions.wrapped_exports(model),
        "execute": provider.execute,
        "flags": dbt.flags,
        # TODO: Do we have to leave this in?
        "graph": manifest.to_flat_graph(),
        "log": log,
        "model": model_dict,
        "modules": {
            "pytz": get_pytz_module_context(),
            "datetime": get_datetime_module_context(),
        },
        "post_hooks": post_hooks,
        "pre_hooks": pre_hooks,
        "ref": provider.ref(db_wrapper, model, config, manifest),
        "return": _return,
        "schema": config.credentials.schema,
        "sql": None,
        "sql_now": adapter.date_function(),
        "source": provider.source(db_wrapper, model, config, manifest),
        "fromjson": fromjson,
        "tojson": tojson,
        "target": target,
        "try_or_compiler_error": try_or_compiler_error(model)
    })

    return context
def generate_base ( model , model_dict , config , manifest , source_config , provider , adapter = None ) : if provider is None : raise dbt . exceptions . InternalException ( "Invalid provider given to context: {}" . format ( provider ) ) target_name = config . target_name target = config . to_profile_info ( ) del target [ 'credentials' ] target . update ( config . credentials . serialize ( with_aliases = True ) ) target [ 'type' ] = config . credentials . type target . pop ( 'pass' , None ) target [ 'name' ] = target_name adapter = get_adapter ( config ) context = { 'env' : target } pre_hooks = None post_hooks = None db_wrapper = DatabaseWrapper ( adapter ) context = dbt . utils . merge ( context , { "adapter" : db_wrapper , "api" : { "Relation" : db_wrapper . Relation , "Column" : adapter . Column , } , "column" : adapter . Column , "config" : provider . Config ( model_dict , source_config ) , "database" : config . credentials . database , "env_var" : env_var , "exceptions" : dbt . exceptions . wrapped_exports ( model ) , "execute" : provider . execute , "flags" : dbt . flags , "graph" : manifest . to_flat_graph ( ) , "log" : log , "model" : model_dict , "modules" : { "pytz" : get_pytz_module_context ( ) , "datetime" : get_datetime_module_context ( ) , } , "post_hooks" : post_hooks , "pre_hooks" : pre_hooks , "ref" : provider . ref ( db_wrapper , model , config , manifest ) , "return" : _return , "schema" : config . credentials . schema , "sql" : None , "sql_now" : adapter . date_function ( ) , "source" : provider . source ( db_wrapper , model , config , manifest ) , "fromjson" : fromjson , "tojson" : tojson , "target" : target , "try_or_compiler_error" : try_or_compiler_error ( model ) } ) return context
Generate the common aspects of the config dict.