<commit_before># Copyright 2017 TensorHub, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from __future__ import absolute_import
from __future__ import division

import re

from pip.commands.download import DownloadCommand
from pip.commands.install import InstallCommand
from pip.commands.search import SearchCommand
from pip.commands.show import ShowCommand
from pip.commands.uninstall import UninstallCommand
from pip.download import _check_download_dir
from pip.download import _download_http_url
from pip.exceptions import HashMismatch as HashMismatch0
from pip.exceptions import UninstallationError
from pip.index import Link
from pip.locations import virtualenv_no_global
from pip.utils import get_installed_distributions
from pip.utils.hashes import Hashes

from guild import cli
from guild import namespace

class NotInstalledError(Exception):

    def __init__(self, req):
        super(NotInstalledError, self).__init__(
            "%s is not installed" % req)
        self.req = req

def install(reqs, index_urls=None, upgrade=False, pre_releases=False,
            no_cache=False, reinstall=False):
    cmd = InstallCommand()
    args = []
    if pre_releases:
        args.append("--pre")
    if not virtualenv_no_global():
        args.append("--user")
    if upgrade:
        args.append("--upgrade")
    if no_cache:
        args.append("--no-cache-dir")
    if reinstall:
        args.append("--force-reinstall")
    if index_urls:
        args.extend(["--index-url", index_urls[0]])
        for url in index_urls[1:]:
            args.extend(["--extra-index-url", url])
    args.extend(reqs)
    options, cmd_args = cmd.parse_args(args)
    cmd.run(options, cmd_args)

def get_installed():
    user_only = not virtualenv_no_global()
    return get_installed_distributions(
        local_only=False,
        user_only=user_only)

def search(terms):
    cmd = SearchCommand()
    args = terms
    options, query = cmd.parse_args(args)
    return cmd.search(query, options)

def uninstall(reqs, dont_prompt=False):
    cmd = UninstallCommand()<commit_msg>Get rid of pointless logging in pip search<commit_after># Copyright 2017 TensorHub, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from __future__ import absolute_import
from __future__ import division

import logging
import re

from pip.commands.download import DownloadCommand
from pip.commands.install import InstallCommand
from pip.commands.search import SearchCommand
from pip.commands.show import ShowCommand
from pip.commands.uninstall import UninstallCommand
from pip.download import _check_download_dir
from pip.download import _download_http_url
from pip.exceptions import HashMismatch as HashMismatch0
from pip.exceptions import UninstallationError
from pip.index import Link
from pip.locations import virtualenv_no_global
from pip.utils import get_installed_distributions
from pip.utils.hashes import Hashes

from guild import cli
from guild import namespace

class NotInstalledError(Exception):

    def __init__(self, req):
        super(NotInstalledError, self).__init__(
            "%s is not installed" % req)
        self.req = req

def install(reqs, index_urls=None, upgrade=False, pre_releases=False,
            no_cache=False, reinstall=False):
    cmd = InstallCommand()
    args = []
    if pre_releases:
        args.append("--pre")
    if not virtualenv_no_global():
        args.append("--user")
    if upgrade:
        args.append("--upgrade")
    if no_cache:
        args.append("--no-cache-dir")
    if reinstall:
        args.append("--force-reinstall")
    if index_urls:
        args.extend(["--index-url", index_urls[0]])
        for url in index_urls[1:]:
            args.extend(["--extra-index-url", url])
    args.extend(reqs)
    options, cmd_args = cmd.parse_args(args)
    cmd.run(options, cmd_args)

def get_installed():
    user_only = not virtualenv_no_global()
    return get_installed_distributions(
        local_only=False,
        user_only=user_only)

def search(terms):
    _ensure_search_logger()
    cmd = SearchCommand()
    args = terms
    options, query = cmd.parse_args(args)
    return cmd.search(query, options)

class QuietLogger(logging.Logger):

    def __init__(self, parent):
        super(QuietLogger, self).__init__(parent.name)
        self.parent = parent
        self.level = logging.WARNING

def _ensure_search_logger():
    from pip._vendor.requests.packages.urllib3 import connectionpool
    if not isinstance(connectionpool.log, QuietLogger):
        connectionpool.log = QuietLogger(connectionpool.log)

def uninstall(reqs, dont_prompt=False):
    cmd = UninstallCommand()
{'fraction_non_alphanumeric': 0.0855567413731768, 'fraction_numerical': 0.004091070793311989, 'mean_word_length': 3.801878736122972, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '63695', 'n_tokens_mistral': 1615, 'n_tokens_neox': 1582, 'n_words': 506}