<commit_before># -*- coding=utf-8 -*-
from __future__ import absolute_import

import os

import click.types
from click import (
    BadParameter, Group, Option, argument, echo, make_pass_decorator, option
)

from .. import environments
from ..utils import is_valid_url


CONTEXT_SETTINGS = dict(help_option_names=["-h", "--help"])


class PipenvGroup(Group):
    """Custom Group class provides formatted main help"""

    def get_help_option(self, ctx):
        from ..core import format_help

        """Override for showing formatted main help via --help and -h options"""
        help_options = self.get_help_option_names(ctx)
        if not help_options or not self.add_help_option:
            return

        def show_help(ctx, param, value):
            if value and not ctx.resilient_parsing:
                if not ctx.invoked_subcommand:
                    # legit main help
                    echo(format_help(ctx.get_help()))
                else:
                    # legit sub-command help
                    echo(ctx.get_help(), color=ctx.color)
                ctx.exit()

        return Option(
            help_options,
            is_flag=True,
            is_eager=True,
            expose_value=False,
            callback=show_help,
            help="Show this message and exit.",
        )


class State(object):
    def __init__(self):
        self.index = None
        self.extra_index_urls = []
        self.verbose = False
        self.pypi_mirror = None
        self.python = None
        self.two = None
        self.three = None
        self.site_packages = False
        self.clear = False
        self.system = False
        self.installstate = InstallState()


class InstallState(object):
    def __init__(self):
        self.dev = False
        self.pre = False
        self.selective_upgrade = False
        self.keep_outdated = False
        self.skip_lock = False
        self.ignore_pipfile = False
        self.sequential = False
        self.code = False
        self.requirementstxt = None
        self.deploy = False
        self.packages = []
        self.editables = []


pass_state = make_pass_decorator(State, ensure=True)


def index_option(f):
    def callback(ctx, param, value):
        state = ctx.ensure_object(State)
        state.index = value
        return value
    return option('-i', '--index', expose_value=False, envvar="PIP_INDEX_URL",
                        help='Target PyPI-compatible package index url.', nargs=1,
                        callback=callback)(f)


def extra_index_option(f):
    def callback(ctx, param, value):
        state = ctx.ensure_object(State)
        state.extra_index_urls.extend(list(value))
        return value
    return option("--extra-index-url", multiple=True, expose_value=False,
        help=u"URLs to the extra PyPI compatible indexes to query for package lookups.",
        callback=callback, envvar="PIP_EXTRA_INDEX_URL")(f)


def editable_option(f):
    def callback(ctx, param, value):
        state = ctx.ensure_object(State)
        state.installstate.editables.extend(validate_requirements(ctx, param, value))
        return value
    return option('-e', '--editable', expose_value=False, multiple=True,
                        help='An editable python package URL or path, often to a VCS repo.',
                        callback=callback)(f)


def sequential_option(f):
    def callback(ctx, param, value):
        state = ctx.ensure_object(State)
        state.installstate.sequential = value
        return value
    return option("--sequential", is_flag=True, default=False, expose_value=False,
                    help="Install dependencies one-at-a-time, instead of concurrently.",
                    callback=callback, type=click.types.BOOL)(f)


def skip_lock_option(f):
    def callback(ctx, param, value):
        state = ctx.ensure_object(State)
        state.installstate.skip_lock = value
        return value
    return option("--skip-lock", is_flag=True, default=False, expose_value=False,
                    help=u"Ignore locking mechanisms when installing—use the Pipfile, instead.",
                    callback=callback, type=click.types.BOOL)(f)


def keep_outdated_option(f):
    def callback(ctx, param, value):
        state = ctx.ensure_object(State)
        state.installstate.keep_outdated = value
        return value
    return option("--keep-outdated", is_flag=True, default=False, expose_value=False,
                    help=u"Keep out-dated dependencies from being updated in Pipfile.lock.",
                    callback=callback, type=click.types.BOOL)(f)


def selective_upgrade_option(f):
    def callback(ctx, param, value):
        state = ctx.ensure_object(State)
        state.installstate.selective_upgrade = value
        return value
    return option("--selective-upgrade", is_flag=True, default=False, type=click.types.BOOL,
                    help="Update specified packages.", callback=callback,
                    expose_value=False)(f)


def ignore_pipfile_option(f):
    def callback(ctx, param, value):
        state = ctx.ensure_object(State)
        state.installstate.ignore_pipfile = value
        return value
    return option("--ignore-pipfile", is_flag=True, default=False, expose_value=False,
                    help="Ignore Pipfile when installing, using the Pipfile.lock.",
                    callback=callback)(f)


def dev_option(f):
    def callback(ctx, param, value):
        state = ctx.ensure_object(State)
        state.installstate.dev = value
        return value
    return option("--dev", "-d", is_flag=True, default=False, type=click.types.BOOL,
                    help="Install both develop and default packages.", callback=callback,
                    expose_value=False)(f)


def pre_option(f):
    def callback(ctx, param, value):
        state = ctx.ensure_object(State)
        state.installstate.pre = value
        return value
    return option("--pre", is_flag=True, default=False, help=u"Allow pre-releases.",
         callback=callback, type=click.types.BOOL, expose_value=False)(f)


def package_arg(f):
    def callback(ctx, param, value):
        state = ctx.ensure_object(State)
        state.installstate.packages.extend(validate_requirements(ctx, param, value))
        return value
    return argument('packages', nargs=-1, callback=callback, expose_value=False,)(f)


def three_option(f):
    def callback(ctx, param, value):
        state = ctx.ensure_object(State)
        if value is not None:
            state.three = value
            state.two = not value
        return value
    return option("--three/--two", is_flag=True, default=None,
                    help="Use Python 3/2 when creating virtualenv.", callback=callback,
                    expose_value=False)(f)


def python_option(f):
    def callback(ctx, param, value):
        state = ctx.ensure_object(State)
        if value is not None:
            state.python = validate_python_path(ctx, param, value)
        return value
    return option("--python", default=False, nargs=1, callback=callback,
                    help="Specify which version of Python virtualenv should use.",
                    expose_value=False)(f)


def pypi_mirror_option(f):
    def callback(ctx, param, value):<commit_msg>Remove unfinished validation<commit_after># -*- coding=utf-8 -*-
from __future__ import absolute_import

import os

import click.types
from click import (
    BadParameter, Group, Option, argument, echo, make_pass_decorator, option
)

from .. import environments
from ..utils import is_valid_url


CONTEXT_SETTINGS = dict(help_option_names=["-h", "--help"])


class PipenvGroup(Group):
    """Custom Group class provides formatted main help"""

    def get_help_option(self, ctx):
        from ..core import format_help

        """Override for showing formatted main help via --help and -h options"""
        help_options = self.get_help_option_names(ctx)
        if not help_options or not self.add_help_option:
            return

        def show_help(ctx, param, value):
            if value and not ctx.resilient_parsing:
                if not ctx.invoked_subcommand:
                    # legit main help
                    echo(format_help(ctx.get_help()))
                else:
                    # legit sub-command help
                    echo(ctx.get_help(), color=ctx.color)
                ctx.exit()

        return Option(
            help_options,
            is_flag=True,
            is_eager=True,
            expose_value=False,
            callback=show_help,
            help="Show this message and exit.",
        )


class State(object):
    def __init__(self):
        self.index = None
        self.extra_index_urls = []
        self.verbose = False
        self.pypi_mirror = None
        self.python = None
        self.two = None
        self.three = None
        self.site_packages = False
        self.clear = False
        self.system = False
        self.installstate = InstallState()


class InstallState(object):
    def __init__(self):
        self.dev = False
        self.pre = False
        self.selective_upgrade = False
        self.keep_outdated = False
        self.skip_lock = False
        self.ignore_pipfile = False
        self.sequential = False
        self.code = False
        self.requirementstxt = None
        self.deploy = False
        self.packages = []
        self.editables = []


pass_state = make_pass_decorator(State, ensure=True)


def index_option(f):
    def callback(ctx, param, value):
        state = ctx.ensure_object(State)
        state.index = value
        return value
    return option('-i', '--index', expose_value=False, envvar="PIP_INDEX_URL",
                        help='Target PyPI-compatible package index url.', nargs=1,
                        callback=callback)(f)


def extra_index_option(f):
    def callback(ctx, param, value):
        state = ctx.ensure_object(State)
        state.extra_index_urls.extend(list(value))
        return value
    return option("--extra-index-url", multiple=True, expose_value=False,
        help=u"URLs to the extra PyPI compatible indexes to query for package lookups.",
        callback=callback, envvar="PIP_EXTRA_INDEX_URL")(f)


def editable_option(f):
    def callback(ctx, param, value):
        state = ctx.ensure_object(State)
        state.installstate.editables.extend(value)
        return value
    return option('-e', '--editable', expose_value=False, multiple=True,
                        help='An editable python package URL or path, often to a VCS repo.',
                        callback=callback)(f)


def sequential_option(f):
    def callback(ctx, param, value):
        state = ctx.ensure_object(State)
        state.installstate.sequential = value
        return value
    return option("--sequential", is_flag=True, default=False, expose_value=False,
                    help="Install dependencies one-at-a-time, instead of concurrently.",
                    callback=callback, type=click.types.BOOL)(f)


def skip_lock_option(f):
    def callback(ctx, param, value):
        state = ctx.ensure_object(State)
        state.installstate.skip_lock = value
        return value
    return option("--skip-lock", is_flag=True, default=False, expose_value=False,
                    help=u"Ignore locking mechanisms when installing—use the Pipfile, instead.",
                    callback=callback, type=click.types.BOOL)(f)


def keep_outdated_option(f):
    def callback(ctx, param, value):
        state = ctx.ensure_object(State)
        state.installstate.keep_outdated = value
        return value
    return option("--keep-outdated", is_flag=True, default=False, expose_value=False,
                    help=u"Keep out-dated dependencies from being updated in Pipfile.lock.",
                    callback=callback, type=click.types.BOOL)(f)


def selective_upgrade_option(f):
    def callback(ctx, param, value):
        state = ctx.ensure_object(State)
        state.installstate.selective_upgrade = value
        return value
    return option("--selective-upgrade", is_flag=True, default=False, type=click.types.BOOL,
                    help="Update specified packages.", callback=callback,
                    expose_value=False)(f)


def ignore_pipfile_option(f):
    def callback(ctx, param, value):
        state = ctx.ensure_object(State)
        state.installstate.ignore_pipfile = value
        return value
    return option("--ignore-pipfile", is_flag=True, default=False, expose_value=False,
                    help="Ignore Pipfile when installing, using the Pipfile.lock.",
                    callback=callback)(f)


def dev_option(f):
    def callback(ctx, param, value):
        state = ctx.ensure_object(State)
        state.installstate.dev = value
        return value
    return option("--dev", "-d", is_flag=True, default=False, type=click.types.BOOL,
                    help="Install both develop and default packages.", callback=callback,
                    expose_value=False)(f)


def pre_option(f):
    def callback(ctx, param, value):
        state = ctx.ensure_object(State)
        state.installstate.pre = value
        return value
    return option("--pre", is_flag=True, default=False, help=u"Allow pre-releases.",
         callback=callback, type=click.types.BOOL, expose_value=False)(f)


def package_arg(f):
    def callback(ctx, param, value):
        state = ctx.ensure_object(State)
        state.installstate.packages.extend(value)
        return value
    return argument('packages', nargs=-1, callback=callback, expose_value=False,)(f)


def three_option(f):
    def callback(ctx, param, value):
        state = ctx.ensure_object(State)
        if value is not None:
            state.three = value
            state.two = not value
        return value
    return option("--three/--two", is_flag=True, default=None,
                    help="Use Python 3/2 when creating virtualenv.", callback=callback,
                    expose_value=False)(f)


def python_option(f):
    def callback(ctx, param, value):
        state = ctx.ensure_object(State)
        if value is not None:
            state.python = validate_python_path(ctx, param, value)
        return value
    return option("--python", default=False, nargs=1, callback=callback,
                    help="Specify which version of Python virtualenv should use.",
                    expose_value=False)(f)


def pypi_mirror_option(f):
    def callback(ctx, param, value):
{'fraction_non_alphanumeric': 0.10094333126764443, 'fraction_numerical': 0.0008262755629002272, 'mean_word_length': 2.383181924062427, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '315147', 'n_tokens_mistral': 4090, 'n_tokens_neox': 3952, 'n_words': 999}