<commit_before>from os import path
import logging

from pynt import task

from .paths import project_paths
from . import project
from .utils import safe_size_check, recursive_pattern_delete
from pyntcontrib import execute, safe_cd


@task()
def venv_bin(*str_args, **kwargs):
    """
    Runs a script in the venv bin w/pynt args/kwargs.
    \t\t\t\t    E.g. pynt venv_bin[django-admin.py]
    """
    project.venv_execute(*str_args, **kwargs)


@task()
def pip(*str_args, **kwargs):
    """Runs the project's pip w/pynt args/kwargs"""
    project.execute_pip(*str_args, **kwargs)


@task()
def python(*str_args, **kwargs):
    """Runs the project's python w/pynt args/kwargs"""
    project.execute_python(*str_args, **kwargs)


@task()
def clean(dry_run='n'):
    """Wipes compiled and cached python files. To simulate: pynt clean[dry_run=y]"""
    file_patterns = ['*.pyc', '*.pyo', '*~']
    dir_patterns = ['__pycache__']
    recursive_pattern_delete(project_paths.root, file_patterns, dir_patterns, dry_run=bool(dry_run.lower() == 'y'))


@task()
def delete_venv():
    """Deletes the venv. Uses a max size check for added safety."""
    safe_size_check(project_paths.venv, "Aborting venv removal for safety.")
    execute('rm', '-rf', project_paths.venv)


@task()
def create_venv(local='y', test='y', general='y'):
    """Create virtualenv w/requirements. Specify y/n for local/test/general to control installation."""
    if not path.isdir(project_paths.venv):
        execute('virtualenv', '--distribute', project_paths.venv)
        project.execute_python('-m', 'easy_install', 'pip')
    if local.lower() == 'y' and project_paths.local_requirements:
        project.execute_pip('install', '--upgrade', '-r', project_paths.local_requirements)
    if test.lower() == 'y' and project_paths.test_requirements:
        project.execute_pip('install', '--upgrade', '-r', project_paths.test_requirements)
    if general.lower() == 'y' and project_paths.requirements_txt:
        project.execute_pip('install', '--upgrade', '-r', project_paths.requirements_txt)


@task()
def recreate_venv():
    """Deletes and re creates virtualenv"""
    delete_venv()
    create_venv()

<commit_msg>Added no-site-packages as default create_venv setting<commit_after>from os import path
import logging

from pynt import task

from .paths import project_paths
from . import project
from .utils import safe_size_check, recursive_pattern_delete
from pyntcontrib import execute, safe_cd


@task()
def venv_bin(*str_args, **kwargs):
    """
    Runs a script in the venv bin w/pynt args/kwargs.
    \t\t\t\t    E.g. pynt venv_bin[django-admin.py]
    """
    project.venv_execute(*str_args, **kwargs)


@task()
def pip(*str_args, **kwargs):
    """Runs the project's pip w/pynt args/kwargs"""
    project.execute_pip(*str_args, **kwargs)


@task()
def python(*str_args, **kwargs):
    """Runs the project's python w/pynt args/kwargs"""
    project.execute_python(*str_args, **kwargs)


@task()
def clean(dry_run='n'):
    """Wipes compiled and cached python files. To simulate: pynt clean[dry_run=y]"""
    file_patterns = ['*.pyc', '*.pyo', '*~']
    dir_patterns = ['__pycache__']
    recursive_pattern_delete(project_paths.root, file_patterns, dir_patterns, dry_run=bool(dry_run.lower() == 'y'))


@task()
def delete_venv():
    """Deletes the venv. Uses a max size check for added safety."""
    safe_size_check(project_paths.venv, "Aborting venv removal for safety.")
    execute('rm', '-rf', project_paths.venv)


@task()
def create_venv(local='y', test='y', general='y'):
    """Create virtualenv w/requirements. Specify y/n for local/test/general to control installation."""
    if not path.isdir(project_paths.venv):
        execute('virtualenv', '--distribute', '--no-site-packages', project_paths.venv)
        project.execute_python('-m', 'easy_install', 'pip')
    if local.lower() == 'y' and project_paths.local_requirements:
        project.execute_pip('install', '--upgrade', '-r', project_paths.local_requirements)
    if test.lower() == 'y' and project_paths.test_requirements:
        project.execute_pip('install', '--upgrade', '-r', project_paths.test_requirements)
    if general.lower() == 'y' and project_paths.requirements_txt:
        project.execute_pip('install', '--upgrade', '-r', project_paths.requirements_txt)


@task()
def recreate_venv():
    """Deletes and re creates virtualenv"""
    delete_venv()
    create_venv()


{'fraction_non_alphanumeric': 0.15209553853086977, 'fraction_numerical': 0.0, 'mean_word_length': 4.341756919374248, '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': '2843419', 'n_tokens_mistral': 1509, 'n_tokens_neox': 1465, 'n_words': 360}