# Path: social/backends/utils.py
# def user_backends_data(user, backends, storage):
#     """
#     Will return backends data for given user, the return value will have the
#     following keys:
#         associated: UserSocialAuth model instances for currently associated
#                     accounts
#         not_associated: Not associated (yet) backend names
#         backends: All backend names.
# 
#     If user is not authenticated, then 'associated' list is empty, and there's
#     no difference between 'not_associated' and 'backends'.
#     """
#     available = list(load_backends(backends).keys())
#     values = {'associated': [],
#               'not_associated': available,
#               'backends': available}
#     if user_is_authenticated(user):
#         associated = storage.user.get_social_auth_for_user(user)
#         not_associated = list(set(available) - set(associated.provider))
#                            #   set(associated.provider for assoc in associated))
#         values['associated'] = associated
#         values['not_associated'] = not_associated
#     return values
# 
# Path: social/apps/flask_app/utils.py
# def get_helper(name, do_import=False):
#     config = current_app.config.get(setting_name(name),
#                                     DEFAULTS.get(name, None))
#     return do_import and module_member(config) or config
# 
# Path: social/utils.py
# def module_member(name):
#     mod, member = name.rsplit('.', 1)
#     module = import_module(mod)
#     return getattr(module, member)


from flask import g, request, session
from social.backends.utils import user_backends_data
from social.apps.flask_app.utils import get_helper
from social.utils import module_member



def backends():
    """Load Social Auth current user data to context under the key 'backends'.
    Will return the output of social.backends.utils.user_backends_data."""
    id = session.get('user_id', None)
    provider = session.get('social_auth_last_login_backend', None)
    storage = get_helper('STORAGE', do_import=True)
    try:
        username = storage.user.get_name(id)
    except:
        username = None
    return {

# Path: social/backends/utils.py
# def user_backends_data(user, backends, storage):
#     """
#     Will return backends data for given user, the return value will have the
#     following keys:
#         associated: UserSocialAuth model instances for currently associated
#                     accounts
#         not_associated: Not associated (yet) backend names
#         backends: All backend names.
# 
#     If user is not authenticated, then 'associated' list is empty, and there's
#     no difference between 'not_associated' and 'backends'.
#     """
#     available = list(load_backends(backends).keys())
#     values = {'associated': [],
#               'not_associated': available,
#               'backends': available}
#     if user_is_authenticated(user):
#         associated = storage.user.get_social_auth_for_user(user)
#         not_associated = list(set(available) - set(associated.provider))
#                            #   set(associated.provider for assoc in associated))
#         values['associated'] = associated
#         values['not_associated'] = not_associated
#     return values
# 
# Path: social/apps/flask_app/utils.py
# def get_helper(name, do_import=False):
#     config = current_app.config.get(setting_name(name),
#                                     DEFAULTS.get(name, None))
#     return do_import and module_member(config) or config
# 
# Path: social/utils.py
# def module_member(name):
#     mod, member = name.rsplit('.', 1)
#     module = import_module(mod)
#     return getattr(module, member)


# Path: social/apps/flask_app/template_filters.py
from flask import g, request, session
from social.backends.utils import user_backends_data
from social.apps.flask_app.utils import get_helper
from social.utils import module_member




def backends():
    """Load Social Auth current user data to context under the key 'backends'.
    Will return the output of social.backends.utils.user_backends_data."""
    id = session.get('user_id', None)
    provider = session.get('social_auth_last_login_backend', None)
    storage = get_helper('STORAGE', do_import=True)
    try:
        username = storage.user.get_name(id)
    except:
        username = None
    return {

        'backends': user_backends_data(g.user,