# Path: yithlibraryserver/email.py
# def send_email_to_admins(request, template, context, subject,
#                          attachments=None, extra_headers=None):
#     admin_emails = request.registry.settings['admin_emails']
#     if admin_emails:
#         return send_email(request, template, context, subject, admin_emails,
#                           attachments, extra_headers)


import bson
from yithlibraryserver.email import send_email_to_admins
    results = db.users.find({
            'email': email,
            '_id': {'$ne': current_user.get('_id', None)},
            }, safe=True)

    if current_user:
        results = [current_user] + list(results)

    accounts = []
    for user in results:
        providers = get_providers(user, current_provider)
        is_current = current_provider in [p['name'] for p in providers]
        accounts.append({
            'providers': providers,
            'is_current': is_current,
            'passwords': get_n_passwords(db, user),
            'id': str(user['_id']),
            'is_verified': user.get('email_verified', False),
            })
    return accounts


def merge_accounts(db, master_user, accounts):
    merged = 0

    for account in accounts:
        user_id = bson.ObjectId(account)
        if master_user['_id'] == user_id:
            continue


# Path: yithlibraryserver/email.py
# def send_email_to_admins(request, template, context, subject,
#                          attachments=None, extra_headers=None):
#     admin_emails = request.registry.settings['admin_emails']
#     if admin_emails:
#         return send_email(request, template, context, subject, admin_emails,
#                           attachments, extra_headers)


# Path: yithlibraryserver/user/accounts.py
import bson
from yithlibraryserver.email import send_email_to_admins

    results = db.users.find({
            'email': email,
            '_id': {'$ne': current_user.get('_id', None)},
            }, safe=True)

    if current_user:
        results = [current_user] + list(results)

    accounts = []
    for user in results:
        providers = get_providers(user, current_provider)
        is_current = current_provider in [p['name'] for p in providers]
        accounts.append({
            'providers': providers,
            'is_current': is_current,
            'passwords': get_n_passwords(db, user),
            'id': str(user['_id']),
            'is_verified': user.get('email_verified', False),
            })
    return accounts


def merge_accounts(db, master_user, accounts):
    merged = 0

    for account in accounts:
        user_id = bson.ObjectId(account)
        if master_user['_id'] == user_id:
            continue


        current_user = db.users.find_one({'_id': user_id}, safe=True)