<commit_before># Copyright 2016, <NAME> and the juno-addresses contributors.

from collections import defaultdict
import argparse
import csv
import sys

from juno_addresses import parser


COLUMNS = [
    'Name',
    'Given Name',
    'Family Name',
    'E-mail 1 - Value',
    'Phone 1 - Type',
    'Phone 1 - Value',
    'Phone 2 - Type',
    'Phone 2 - Value',
    'Address 1 - Formatted',
]


def format_name(name):
    full = name
    first = last = ''
    names = name.split(',', 1)
    if len(names) == 2:
        first = names[1].strip()
        last = names[0].strip()
        full = '{} {}'.format(first, last)
    return (full, first, last)


def format_address(address):
    return ' '.join(address)


def format_addresses(input, output, include_deleted=False):
    writer = csv.writer(output)
    writer.writerow(COLUMNS)

    for entry in parser.parser(input):
        print(entry)
        if entry['Type'] == 'Entry' and (include_deleted or not entry['Deleted']):
            e = defaultdict(str)
            for k, v in entry.items():
                e[k] = v
                row = format_name(e['Name']) + \
                      ( e['Email'],
                        'Home', e['Primary Phone'],
                        'Mobile', e['Mobile Phone'],
                        format_address(e['Address']) )
            writer.writerow(row)


def main():
    arg_parser = argparse.ArgumentParser(
        description='Convert a Juno address book into a Gmail compatible CSV file.')
    arg_parser.add_argument(
        'input',
        nargs='?',
        type=argparse.FileType('r'),
        default=sys.stdin,
        help='Juno address book file (addrbook.nv). Defaults to stdin.')
    arg_parser.add_argument(
        'output',
        nargs='?',
        type=argparse.FileType('w'),
        default=sys.stdout, help='Output file. Defaults to stdout.')
    arg_parser.add_argument(
        '-d', '--deleted',
        action='store_true',
        help='Include deleted entries')
    args = arg_parser.parse_args()
    print(args)
    format_addresses(args.input, args.output, include_deleted=args.deleted)


if __name__ == '__main__':
    main()<commit_msg>Remove print statement<commit_after># Copyright 2016, <NAME> and the juno-addresses contributors.

from collections import defaultdict
import argparse
import csv
import sys

from juno_addresses import parser


COLUMNS = [
    'Name',
    'Given Name',
    'Family Name',
    'E-mail 1 - Value',
    'Phone 1 - Type',
    'Phone 1 - Value',
    'Phone 2 - Type',
    'Phone 2 - Value',
    'Address 1 - Formatted',
]


def format_name(name):
    full = name
    first = last = ''
    names = name.split(',', 1)
    if len(names) == 2:
        first = names[1].strip()
        last = names[0].strip()
        full = '{} {}'.format(first, last)
    return (full, first, last)


def format_address(address):
    return ' '.join(address)


def format_addresses(input, output, include_deleted=False):
    writer = csv.writer(output)
    writer.writerow(COLUMNS)

    for entry in parser.parser(input):
        print(entry)
        if entry['Type'] == 'Entry' and (include_deleted or not entry['Deleted']):
            e = defaultdict(str)
            for k, v in entry.items():
                e[k] = v
                row = format_name(e['Name']) + \
                      ( e['Email'],
                        'Home', e['Primary Phone'],
                        'Mobile', e['Mobile Phone'],
                        format_address(e['Address']) )
            writer.writerow(row)


def main():
    arg_parser = argparse.ArgumentParser(
        description='Convert a Juno address book into a Gmail compatible CSV file.')
    arg_parser.add_argument(
        'input',
        nargs='?',
        type=argparse.FileType('r'),
        default=sys.stdin,
        help='Juno address book file (addrbook.nv). Defaults to stdin.')
    arg_parser.add_argument(
        'output',
        nargs='?',
        type=argparse.FileType('w'),
        default=sys.stdout, help='Output file. Defaults to stdout.')
    arg_parser.add_argument(
        '-d', '--deleted',
        action='store_true',
        help='Include deleted entries')
    args = arg_parser.parse_args()
    format_addresses(args.input, args.output, include_deleted=args.deleted)


if __name__ == '__main__':
    main()
{'fraction_non_alphanumeric': 0.13511643993543923, 'fraction_numerical': 0.006456075628314503, 'mean_word_length': 2.266566265060241, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '5181248', 'n_tokens_mistral': 1351, 'n_tokens_neox': 1300, 'n_words': 336}