<commit_before>"""

Usage:
    scripts/generate-user-email-list.py <data_api_url> <data_api_token>
"""
import csv
import sys

from docopt import docopt
from dmutils.apiclient import DataAPIClient


def generate_user_email_list(data_api_url, data_api_token):
    client = DataAPIClient(data_api_url, data_api_token)

    writer = csv.writer(sys.stdout, delimiter=',', quotechar='"')

    for user in client.find_users_iter():
        if user['active'] and user['role'] == 'supplier':
            writer.writerow([
                user['emailAddress'],
                user['name'],
                user['supplier']['supplierId'],
                user['supplier']['name']])


if __name__ == '__main__':
    arguments = docopt(__doc__)

    generate_user_email_list(
        data_api_url=arguments['<data_api_url>'],
        data_api_token=arguments['<data_api_token>'])<commit_msg>Python 2.7 unicode bug<commit_after>"""

Usage:
    scripts/generate-user-email-list.py <data_api_url> <data_api_token>
"""
import csv
import sys

from docopt import docopt
from dmutils.apiclient import DataAPIClient


def generate_user_email_list(data_api_url, data_api_token):
    client = DataAPIClient(data_api_url, data_api_token)

    writer = csv.writer(sys.stdout, delimiter=',', quotechar='"')

    for user in client.find_users_iter():
        if user['active'] and user['role'] == 'supplier':
            writer.writerow([
                user['emailAddress'].encode('utf-8'),
                user['name'].encode('utf-8'),
                user['supplier']['supplierId'],
                user['supplier']['name'].encode('utf-8')])


if __name__ == '__main__':
    arguments = docopt(__doc__)

    generate_user_email_list(
        data_api_url=arguments['<data_api_url>'],
        data_api_token=arguments['<data_api_token>'])
{'fraction_non_alphanumeric': 0.1393939393939394, 'fraction_numerical': 0.0027548209366391185, 'mean_word_length': 3.4839506172839507, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3611429', 'n_tokens_mistral': 593, 'n_tokens_neox': 577, 'n_words': 100}