<commit_before>from __future__ import absolute_import
import sys

from conda.cli import common
from conda import plan


def install(prefix, specs, args, data):
    # TODO: do we need this?
    common.check_specs(prefix, specs, json=args.json)

    # TODO: support all various ways this happens
    index = common.get_index_trap()
    actions = plan.install_actions(prefix, index, specs)
    if plan.nothing_to_do(actions):
        sys.stderr.write('# TODO handle more gracefully')
        sys.exit(-1)

    with common.json_progress_bars(json=args.json and not args.quiet):
        try:
            plan.execute_actions(actions, index, verbose=not args.quiet)
        except RuntimeError as e:
            if len(e.args) > 0 and "LOCKERROR" in e.args[0]:
                error_type = "AlreadyLocked"
            else:
                error_type = "RuntimeError"
            common.exception_and_exit(e, error_type=error_type, json=args.json)
        except SystemExit as e:
            common.exception_and_exit(e, json=args.json)

<commit_msg>Add support for channels in the spec<commit_after>from __future__ import absolute_import
import sys

from conda.cli import common
from conda import plan


def install(prefix, specs, args, data):
    # TODO: do we need this?
    common.check_specs(prefix, specs, json=args.json)

    # TODO: support all various ways this happens
    index = common.get_index_trap(
        channel_urls=data.get('channels', ())
    )
    actions = plan.install_actions(prefix, index, specs)
    if plan.nothing_to_do(actions):
        sys.stderr.write('# TODO handle more gracefully')
        sys.exit(-1)

    with common.json_progress_bars(json=args.json and not args.quiet):
        try:
            plan.execute_actions(actions, index, verbose=not args.quiet)
        except RuntimeError as e:
            if len(e.args) > 0 and "LOCKERROR" in e.args[0]:
                error_type = "AlreadyLocked"
            else:
                error_type = "RuntimeError"
            common.exception_and_exit(e, error_type=error_type, json=args.json)
        except SystemExit as e:
            common.exception_and_exit(e, json=args.json)


{'fraction_non_alphanumeric': 0.09204440333024977, 'fraction_numerical': 0.0027752081406105457, 'mean_word_length': 2.748700173310225, 'pattern_counts': {'":': 0, '<': 3, '<?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': '5911278', 'n_tokens_mistral': 662, 'n_tokens_neox': 635, 'n_words': 173}