<commit_before>import click
import json
import urllib.request
import tarfile
import os
import os.path
import subprocess
import operator

_config_file = os.path.expanduser('~/.pear')

@click.group()
@click.version_option()
@click.pass_context
def cli(ctx):
    ctx.obj = {}
    if not os.path.isfile(_config_file):
        with open(_config_file, 'a'):
            pass
    with open(_config_file, 'r') as f:
        contents = f.read().strip()
    try:
        ctx.obj['packages'] = dict(map(lambda x: x.strip().split(' '), contents.split('\n')))
    except ValueError:
        pass



@cli.command()
@click.argument('string')
def query(string):
    f = urllib.request.urlopen('https://aur4.archlinux.org/rpc.php?type=search&arg={}'.format(string))
    details = map(operator.itemgetter('Name', 'Version', 'Description'),
                  json.loads(f.read().decode('utf8'))['results'])
    formatted = map(lambda x: '{} - {}\n : {}\n----'.format(*x),
                    details)
    print('\n'.join(formatted))

def get_package(package):
    f = urllib.request.urlopen('https://aur4.archlinux.org/rpc.php?type=info&arg={}'.format(package))
    result = json.loads(f.read().decode('utf8'))
    packages = result['resultcount']
    if packages != 1:
        return None
    result = result['results']
    return result

@cli.command()
@click.pass_context
def upgrade(ctx):
    local_packages = ctx.obj.get('packages', {}).items()
    remote_packages = map(get_package, map(operator.itemgetter(0), local_packages))
    remote_package_versions = map(lambda x: x and x['Version'], remote_packages)
    for (n, lv), rv in zip(local_packages, remote_package_versions):
        if rv is None:
            print('failed to find {} on server'.format(n))
            continue
        print(n, lv, rv)
        if lv != rv:
            print('upgrading {} from {} to {}'.format(n, lv, rv))
            install(ctx, n)
    print('done')


@cli.command(name='list')
@click.pass_context
def listpackages(ctx):
    local_packages = sorted(ctx.obj.get('packages', {}).items(), key=operator.itemgetter(0))
    for p, v in local_packages:
        print(p, v)

def install(ctx, package):<commit_msg>Add better output when installing<commit_after>import click
import json
import urllib.request
import tarfile
import os
import os.path
import subprocess
import operator

_config_file = os.path.expanduser('~/.pear')

@click.group()
@click.version_option()
@click.pass_context
def cli(ctx):
    ctx.obj = {}
    if not os.path.isfile(_config_file):
        with open(_config_file, 'a'):
            pass
    with open(_config_file, 'r') as f:
        contents = f.read().strip()
    try:
        ctx.obj['packages'] = dict(map(lambda x: x.strip().split(' '), contents.split('\n')))
    except ValueError:
        pass



@cli.command()
@click.argument('string')
def query(string):
    f = urllib.request.urlopen('https://aur4.archlinux.org/rpc.php?type=search&arg={}'.format(string))
    details = map(operator.itemgetter('Name', 'Version', 'Description'),
                  json.loads(f.read().decode('utf8'))['results'])
    formatted = map(lambda x: '{} - {}\n : {}\n----'.format(*x),
                    details)
    print('\n'.join(formatted))

def get_package(package):
    f = urllib.request.urlopen('https://aur4.archlinux.org/rpc.php?type=info&arg={}'.format(package))
    result = json.loads(f.read().decode('utf8'))
    packages = result['resultcount']
    if packages != 1:
        return None
    result = result['results']
    return result

@cli.command()
@click.pass_context
def upgrade(ctx):
    local_packages = ctx.obj.get('packages', {}).items()
    remote_packages = map(get_package, map(operator.itemgetter(0), local_packages))
    remote_package_versions = map(lambda x: x and x['Version'], remote_packages)
    for (n, lv), rv in zip(local_packages, remote_package_versions):
        if rv is None:
            print('failed to find {} on server'.format(n))
            continue
        elif lv != rv:
            print('upgrading {} from {} to {}'.format(n, lv, rv))
            install(ctx, n)
        else:
            print('{} is up to date'.format(n))
    print('done')


@cli.command(name='list')
@click.pass_context
def listpackages(ctx):
    local_packages = sorted(ctx.obj.get('packages', {}).items(), key=operator.itemgetter(0))
    for p, v in local_packages:
        print(p, v)

def install(ctx, package):
{'fraction_non_alphanumeric': 0.16557339968332957, 'fraction_numerical': 0.003166704365528161, 'mean_word_length': 3.231578947368421, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 4, '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': '61078', 'n_tokens_mistral': 1427, 'n_tokens_neox': 1423, 'n_words': 306}