<commit_before># -*- coding: utf-8 -*-

"""
fabrik.ext.virtualenv
---------------------------
Holds methods for managing virtualenv.
"""

import os
from unipath import Path
from fabric.decorators import task
from fabric.operations import prompt
from fabric.state import env

from fabrik import paths
from ..logger import logger


@task
def create_venv():
    if "venv_path" not in env:
        raise Exception("No env.venv_path has been specified")

    # Checks if venv exist and prompts user if reinstalling is an option
    if env.exists(Path(get_path(), "bin")):
        logger.warn("Virtualenv is already installed")
        prompt_result = prompt("Install anyways:", default="no")

        if prompt_result == "no":
            return

    env.run("virtualenv %s" % get_path())


@task
def update_requirements():
    req_dir = os.path.join(env.current_release, "requirements")
    req_path = None

    if "requirements" in env:
        req_path = Path(req_dir, env.requirements)

    if not req_path:
        req_path = Path(req_dir, "%s.txt" % env.stage)<commit_msg>Made it possible to override requirement search folder<commit_after># -*- coding: utf-8 -*-

"""
fabrik.ext.virtualenv
---------------------------
Holds methods for managing virtualenv.
"""

import os
from unipath import Path
from fabric.decorators import task
from fabric.operations import prompt
from fabric.state import env

from fabrik import paths
from ..logger import logger


@task
def create_venv():
    if "venv_path" not in env:
        raise Exception("No env.venv_path has been specified")

    # Checks if venv exist and prompts user if reinstalling is an option
    if env.exists(Path(get_path(), "bin")):
        logger.warn("Virtualenv is already installed")
        prompt_result = prompt("Install anyways:", default="no")

        if prompt_result == "no":
            return

    env.run("virtualenv %s" % get_path())


@task
def update_requirements():
    req_dir = None
    req_path = None

    if "requirements_root" in env:
        req_dir = os.path.join(env.current_release, env.requirements_root)

    if not req_dir:
        req_dir = os.path.join(env.current_release, "requirements")

    if "requirements" in env:
        req_path = Path(req_dir, env.requirements)

    if not req_path:
        req_path = Path(req_dir, "%s.txt" % env.stage)
{'fraction_non_alphanumeric': 0.12425277540563621, 'fraction_numerical': 0.0008539709649871904, 'mean_word_length': 2.9846938775510203, 'pattern_counts': {'":': 2, '<': 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': '3709166', 'n_tokens_mistral': 711, 'n_tokens_neox': 688, 'n_words': 220}