# Path: yithlibraryserver/user/accounts.py
# def get_available_providers():
#     return ('facebook', 'google', 'twitter', 'persona')
# 
# Path: yithlibraryserver/user/accounts.py
# def get_provider_key(provider):
#     return '%s_id' % provider
# 
# def get_n_passwords(db, user):
#     return db.passwords.find({
#             'owner': user.get('_id', None),
#             }, safe=True).count()
# 
# Path: yithlibraryserver/scripts/utils.py
# def safe_print(value):
#     if PY3:  # pragma: no cover
#         print(value)
#     else:  # pragma: no cover
#         print(value.encode('utf-8'))
# 
# def setup_simple_command(name, description):
#     usage = name + ": %prog config_uri"
#     parser = optparse.OptionParser(
#         usage=usage,
#         description=textwrap.dedent(description)
#         )
#     options, args = parser.parse_args(sys.argv[1:])
#     if not len(args) >= 1:
#         safe_print('You must provide at least one argument')
#         return 2
#     config_uri = args[0]
#     env = bootstrap(config_uri)
#     settings, closer = env['registry'].settings, env['closer']
# 
#     return settings, closer, env, args[1:]
# 
# Path: yithlibraryserver/scripts/utils.py
# def get_user_display_name(user):
#     return '%s %s <%s>' % (user.get('first_name', ''),
#                            user.get('last_name', ''),
#                            user.get('email', ''))


import operator
from yithlibraryserver.user.accounts import get_available_providers
from yithlibraryserver.user.accounts import get_provider_key, get_n_passwords
from yithlibraryserver.scripts.utils import safe_print, setup_simple_command
from yithlibraryserver.scripts.utils import get_user_display_name
        "applications",
        "Report information about oauth2 client applications.",
        )
    if isinstance(result, int):
        return result
    else:
        settings, closer, env, args = result

    try:
        db = settings['mongodb'].get_database()
        for app in db.applications.find():
            info = _get_app_info(db, app)
            text = ('%s\n'
                    '\tOwner: %s\n'
                    '\tMain URL: %s\n'
                    '\tCallback URL: %s\n'
                    '\tUsers: %d\n' % (
                    info['name'], info['owner'],
                    info['main_url'], info['callback_url'],
                    info['users'],
                    ))
            safe_print(text)

    finally:
        closer()


def group_by_identity_provider(users):
    providers = {}
    for user in users:

# Path: yithlibraryserver/user/accounts.py
# def get_available_providers():
#     return ('facebook', 'google', 'twitter', 'persona')
# 
# Path: yithlibraryserver/user/accounts.py
# def get_provider_key(provider):
#     return '%s_id' % provider
# 
# def get_n_passwords(db, user):
#     return db.passwords.find({
#             'owner': user.get('_id', None),
#             }, safe=True).count()
# 
# Path: yithlibraryserver/scripts/utils.py
# def safe_print(value):
#     if PY3:  # pragma: no cover
#         print(value)
#     else:  # pragma: no cover
#         print(value.encode('utf-8'))
# 
# def setup_simple_command(name, description):
#     usage = name + ": %prog config_uri"
#     parser = optparse.OptionParser(
#         usage=usage,
#         description=textwrap.dedent(description)
#         )
#     options, args = parser.parse_args(sys.argv[1:])
#     if not len(args) >= 1:
#         safe_print('You must provide at least one argument')
#         return 2
#     config_uri = args[0]
#     env = bootstrap(config_uri)
#     settings, closer = env['registry'].settings, env['closer']
# 
#     return settings, closer, env, args[1:]
# 
# Path: yithlibraryserver/scripts/utils.py
# def get_user_display_name(user):
#     return '%s %s <%s>' % (user.get('first_name', ''),
#                            user.get('last_name', ''),
#                            user.get('email', ''))


# Path: yithlibraryserver/scripts/reports.py
import operator
from yithlibraryserver.user.accounts import get_available_providers
from yithlibraryserver.user.accounts import get_provider_key, get_n_passwords
from yithlibraryserver.scripts.utils import safe_print, setup_simple_command
from yithlibraryserver.scripts.utils import get_user_display_name

        "applications",
        "Report information about oauth2 client applications.",
        )
    if isinstance(result, int):
        return result
    else:
        settings, closer, env, args = result

    try:
        db = settings['mongodb'].get_database()
        for app in db.applications.find():
            info = _get_app_info(db, app)
            text = ('%s\n'
                    '\tOwner: %s\n'
                    '\tMain URL: %s\n'
                    '\tCallback URL: %s\n'
                    '\tUsers: %d\n' % (
                    info['name'], info['owner'],
                    info['main_url'], info['callback_url'],
                    info['users'],
                    ))
            safe_print(text)

    finally:
        closer()


def group_by_identity_provider(users):
    providers = {}
    for user in users:

        for provider in get_available_providers():