# 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
            }, multi=True, safe=True)

    # copy authorized_apps from user2 to user1
    updates = {
        '$addToSet': {
            'authorized_apps': {
                '$each': user2['authorized_apps'],
                },
            },
        }

    # copy the providers
    for provider in get_available_providers():
        key = provider + '_id'
        if key in user2 and key not in user1:
            sets = updates.setdefault('$set', {})
            sets[key] = user2[key]

    db.users.update({'_id': user1['_id']}, updates, safe=True)

    # remove user2
    db.users.remove(user2['_id'])


def notify_admins_of_account_removal(request, user, reason):
    context = {
        'reason': reason or 'no reason was given',
        'user': user,
        'home_link': request.route_url('home'),
    }

# 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

            }, multi=True, safe=True)

    # copy authorized_apps from user2 to user1
    updates = {
        '$addToSet': {
            'authorized_apps': {
                '$each': user2['authorized_apps'],
                },
            },
        }

    # copy the providers
    for provider in get_available_providers():
        key = provider + '_id'
        if key in user2 and key not in user1:
            sets = updates.setdefault('$set', {})
            sets[key] = user2[key]

    db.users.update({'_id': user1['_id']}, updates, safe=True)

    # remove user2
    db.users.remove(user2['_id'])


def notify_admins_of_account_removal(request, user, reason):
    context = {
        'reason': reason or 'no reason was given',
        'user': user,
        'home_link': request.route_url('home'),
    }

    return send_email_to_admins(