<commit_before>"""
@brief
@file Batch file use to automate some of the tasks (setup, unit tests, help, pypi).

.. versionadded:: 1.1
"""
import sys


def _sversion():
    return "PY%d%d" % sys.version_info[:2]

#################
#: stop if error
#################
windows_error = "if %errorlevel% neq 0 exit /b %errorlevel%"

#################
#: prefix
#################
windows_prefix = """
@echo off
if "%1"=="" goto default_value_python:
if "%1"=="default" goto default_value_python:
set pythonexe=%1
goto start_script:

:default_value_python:
set pythonexe=__PY??_X64__\\python

@echo ~SET pythonexe=%pythonexe%

:start_script:
set current=%~dp0
@echo ~SET current=%current%
""".replace("PY??", _sversion())

#################
#: prefix 27
#################
windows_prefix_27 = """
@echo off
if "%1"=="" goto default_value_python:
if "%1"=="default" goto default_value_python:
set pythonexe27=%1
goto start_script:

:default_value_python:
set pythonexe27=__PY27_X64__\\python
:start_script:
@echo ~SET pythonexe27=%pythonexe27%
"""

#################
#: run unit test 27
#################
windows_unittest27 = """
@echo off
set PYTHONPATH=
@echo ~SET PYTHONPATH=
cd dist_module27\\_unittests

rem errorlevel does not work well in a loop
rem for /d %%d in (ut_*) do (
rem     @echo ~CALL %pythonexe27%\\..\\Scripts\\nosetests.exe -w %%d
rem     %pythonexe27%\\..\\Scripts\\nosetests.exe -w %%d
rem     if %errorlevel% neq 0 exit /b %errorlevel%
rem )

__LOOP_UNITTEST_FOLDERS__

""" + windows_error + "\ncd ..\.."

####################################################
#: build any script for Windows from a virtual environment
####################################################
windows_any_setup_command_base = """
@echo off
if "%1"=="" @echo usage: SCRIPT [pythonpath] [suffix] [command] [...]
set CURRENT_THIS=%~dp0
@echo ~SET CURRENT_THIS=%CURRENT_THIS%

IF EXIST dist del /Q dist\\*.*
IF EXIST build del /Q build\\*.*

if "%2"=="" goto default_value_suffix:
if "%2"=="default" goto default_value_suffix:
set virtual_env_suffix=%2
goto default_value_suffix_next:
:default_value_suffix:
set virtual_env_suffix=_anyenv
:default_value_suffix_next:
@echo ~SET set virtual_env_suffix=%virtual_env_suffix%

if "%1"=="" goto default_value:
if "%1"=="default" goto default_value:
set pythonexe=%1
goto default_value_next:
:default_value:
set pythonexe=__PY??_X64__\\python
:default_value_next:

echo ###----################################################5
SET ROOT_VIRTUAL_ENV=%CURRENT_THIS%_virtualenv
if not exist %ROOT_VIRTUAL_ENV% mkdir %ROOT_VIRTUAL_ENV%
set virtual_env_py=%ROOT_VIRTUAL_ENV%\\__MODULE__
@echo ~SET virtual_env_py=%ROOT_VIRTUAL_ENV%\\__MODULE__
if not exist %pythonexe%\\..\\Scripts\\virtualenv.exe goto conda_virtual_env:

if exist %virtual_env_py%_vir%virtual_env_suffix% rmdir /Q /S %virtual_env_py%_vir%virtual_env_suffix%
mkdir %virtual_env_py%_vir%virtual_env_suffix%

if exist %virtual_env_py%_vir%virtual_env_suffix%\\python goto with_virtual:
set KEEPPATH=%PATH%
@echo ~SET KEEPPATH=%PATH%
set PATH=%pythonexe%\\..;%PATH%
@echo ~SET PATH=%pythonexe%\\..;%PATH%
@echo ~CALL %pythonexe%\\..\\Scripts\\virtualenv --system-site-packages %virtual_env_py%_vir%virtual_env_suffix%
%pythonexe%\\..\\Scripts\\virtualenv --system-site-packages %virtual_env_py%_vir%virtual_env_suffix%
@echo ### VIRTUAL ENVIRONMENT CREATED in %virtual_env_py%_vir%virtual_env_suffix%

@echo on
rem _PATH_VIRTUAL_ENV_
@echo off

:with_virtual:
@echo ~LABEL with_virtual
set pythonexe=%virtual_env_py%_vir%virtual_env_suffix%\\Scripts\\python
@echo ~SET pythonexe=%virtual_env_py%_vir%virtual_env_suffix%\\Scripts\\python
set pythonpip=%virtual_env_py%_vir%virtual_env_suffix%\\Scripts\\pip
@echo ~SET pythonpip=%virtual_env_py%_vir%virtual_env_suffix%\\Scripts\\pip
goto requirements:

:conda_virtual_env:
@echo ~LABEL conda_virtual_env
if exist %virtual_env_py%_condavir%virtual_env_suffix% rmdir /Q /S %virtual_env_py%_condavir%virtual_env_suffix%

if exist %virtual_env_py%_condavir%virtual_env_suffix%\\python goto with_virtual_conda:

@echo ~CALL %pythonexe%\\..\\Scripts\\conda create -p %virtual_env_py%_condavir%virtual_env_suffix% --clone %pythonexe%\\.. --offline
%pythonexe%\\..\\Scripts\\conda create -p %virtual_env_py%_condavir%virtual_env_suffix% --clone %pythonexe%\\.. --offline
if %errorlevel% neq 0 exit /b %errorlevel%

:with_virtual_conda:
@echo ~LABEL with_virtual_conda
set pythonexe=%virtual_env_py%_condavir%virtual_env_suffix%\\python
@echo ~SET pythonexe=%virtual_env_py%_condavir%virtual_env_suffix%\\python
set pythonpip=%virtual_env_py%_condavir%virtual_env_suffix%\\Scripts\\pip
@echo ~SET pythonpip=%virtual_env_py%_condavir%virtual_env_suffix%\\Scripts\\pip

:requirements:
@echo #######################################################_auto_setup_dep.py
cd build\\auto_setup
set pythonexe_rel=..\\..\\%pythonexe%.exe
@echo ~SET pythonexe_rel=..\\..\\%pythonexe%.exe
if exist %pythonexe_rel% goto auto_setup_relpath:
set pythonexe_rel=%pythonexe%
@echo ~SET pythonexe_rel=%pythonexe%

:auto_setup_relpath:
@echo ~LABAL auto_setup_relpath
@echo ~CALL %pythonexe_rel% auto_setup_dep.py install
%pythonexe_rel% auto_setup_dep.py install
if %errorlevel% neq 0 exit /b %errorlevel%
cd ..\\..
@echo #######################################################_auto_setup_dep.py END

@echo #######################################################_requirements_begin
@echo ~SET %pythonpip%
__REQUIREMENTS__
if %errorlevel% neq 0 exit /b %errorlevel%
@echo #######################################################_requirements_end<commit_msg>update script info<commit_after>"""
@brief
@file Batch file use to automate some of the tasks (setup, unit tests, help, pypi).

.. versionadded:: 1.1
"""
import sys


def _sversion():
    return "PY%d%d" % sys.version_info[:2]

#################
#: stop if error
#################
windows_error = "if %errorlevel% neq 0 exit /b %errorlevel%"

#################
#: prefix
#################
windows_prefix = """
@echo off
if "%1"=="" goto default_value_python:
if "%1"=="default" goto default_value_python:
set pythonexe=%1
goto start_script:

:default_value_python:
set pythonexe=__PY??_X64__\\python

@echo ~SET pythonexe=%pythonexe%

:start_script:
set current=%~dp0
@echo ~SET current=%current%
""".replace("PY??", _sversion())

#################
#: prefix 27
#################
windows_prefix_27 = """
@echo off
if "%1"=="" goto default_value_python:
if "%1"=="default" goto default_value_python:
set pythonexe27=%1
goto start_script:

:default_value_python:
set pythonexe27=__PY27_X64__\\python
:start_script:
@echo ~SET pythonexe27=%pythonexe27%
"""

#################
#: run unit test 27
#################
windows_unittest27 = """
@echo off
set PYTHONPATH=
@echo ~SET PYTHONPATH=
cd dist_module27\\_unittests

rem errorlevel does not work well in a loop
rem for /d %%d in (ut_*) do (
rem     @echo ~CALL %pythonexe27%\\..\\Scripts\\nosetests.exe -w %%d
rem     %pythonexe27%\\..\\Scripts\\nosetests.exe -w %%d
rem     if %errorlevel% neq 0 exit /b %errorlevel%
rem )

__LOOP_UNITTEST_FOLDERS__

""" + windows_error + "\ncd ..\.."

####################################################
#: build any script for Windows from a virtual environment
####################################################
windows_any_setup_command_base = """
@echo off
if "%1"=="" @echo usage: SCRIPT [pythonpath] [suffix] [command] [...]
set CURRENT_THIS=%~dp0
@echo ~SET CURRENT_THIS=%CURRENT_THIS%

IF EXIST dist del /Q dist\\*.*
IF EXIST build del /Q build\\*.*

if "%2"=="" goto default_value_suffix:
if "%2"=="default" goto default_value_suffix:
set virtual_env_suffix=%2
goto default_value_suffix_next:
:default_value_suffix:
set virtual_env_suffix=_anyenv
:default_value_suffix_next:
@echo ~SET set virtual_env_suffix=%virtual_env_suffix%

if "%1"=="" goto default_value:
if "%1"=="default" goto default_value:
set pythonexe=%1
goto default_value_next:
:default_value:
set pythonexe=__PY??_X64__\\python
:default_value_next:

echo ###----################################################5
SET ROOT_VIRTUAL_ENV=%CURRENT_THIS%_virtualenv
if not exist %ROOT_VIRTUAL_ENV% mkdir %ROOT_VIRTUAL_ENV%
set virtual_env_py=%ROOT_VIRTUAL_ENV%\\__MODULE__
@echo ~SET virtual_env_py=%ROOT_VIRTUAL_ENV%\\__MODULE__
if not exist %pythonexe%\\..\\Scripts\\virtualenv.exe goto conda_virtual_env:

if exist %virtual_env_py%_vir%virtual_env_suffix% rmdir /Q /S %virtual_env_py%_vir%virtual_env_suffix%
mkdir %virtual_env_py%_vir%virtual_env_suffix%

if exist %virtual_env_py%_vir%virtual_env_suffix%\\python goto with_virtual:
set KEEPPATH=%PATH%
@echo ~SET KEEPPATH=%PATH%
set PATH=%pythonexe%\\..;%PATH%
@echo ~SET PATH=%pythonexe%\\..;%PATH%
@echo ~CALL %pythonexe%\\..\\Scripts\\virtualenv --system-site-packages %virtual_env_py%_vir%virtual_env_suffix%
%pythonexe%\\..\\Scripts\\virtualenv --system-site-packages %virtual_env_py%_vir%virtual_env_suffix%
@echo ### VIRTUAL ENVIRONMENT CREATED in %virtual_env_py%_vir%virtual_env_suffix%

@echo on
rem _PATH_VIRTUAL_ENV_
@echo off

:with_virtual:
@echo ~LABEL with_virtual
set pythonexe=%virtual_env_py%_vir%virtual_env_suffix%\\Scripts\\python
@echo ~SET pythonexe=%virtual_env_py%_vir%virtual_env_suffix%\\Scripts\\python
set pythonpip=%virtual_env_py%_vir%virtual_env_suffix%\\Scripts\\pip
@echo ~SET pythonpip=%virtual_env_py%_vir%virtual_env_suffix%\\Scripts\\pip
goto requirements:

:conda_virtual_env:
@echo ~LABEL conda_virtual_env
if exist %virtual_env_py%_condavir%virtual_env_suffix% rmdir /Q /S %virtual_env_py%_condavir%virtual_env_suffix%

if exist %virtual_env_py%_condavir%virtual_env_suffix%\\python goto with_virtual_conda:

@echo ~CALL %pythonexe%\\..\\Scripts\\conda create -p %virtual_env_py%_condavir%virtual_env_suffix% --clone %pythonexe%\\.. --offline
%pythonexe%\\..\\Scripts\\conda create -p %virtual_env_py%_condavir%virtual_env_suffix% --clone %pythonexe%\\.. --offline
if %errorlevel% neq 0 exit /b %errorlevel%

:with_virtual_conda:
@echo ~LABEL with_virtual_conda
set pythonexe=%virtual_env_py%_condavir%virtual_env_suffix%\\python
@echo ~SET pythonexe=%virtual_env_py%_condavir%virtual_env_suffix%\\python
set pythonpip=%virtual_env_py%_condavir%virtual_env_suffix%\\Scripts\\pip
@echo ~SET pythonpip=%virtual_env_py%_condavir%virtual_env_suffix%\\Scripts\\pip

:requirements:
@echo #######################################################_auto_setup_dep.py
cd build\\auto_setup
set pythonexe_rel=..\\..\\%pythonexe%.exe
@echo ~SET pythonexe_rel=..\\..\\%pythonexe%.exe
if exist %pythonexe_rel% goto auto_setup_relpath:
set pythonexe_rel=%pythonexe%
@echo ~SET pythonexe_rel=%pythonexe%

:auto_setup_relpath:
@echo ~LABAL auto_setup_relpath
@echo ~CALL %pythonexe_rel% auto_setup_dep.py install
%pythonexe_rel% auto_setup_dep.py install > auto_setup_dep.log
rem if %errorlevel% neq 0 exit /b %errorlevel%
rem we continue to run the script even if it seems to fail
cd ..\\..
@echo #######################################################_auto_setup_dep.py END

@echo #######################################################_requirements_begin
@echo ~SET %pythonpip%
__REQUIREMENTS__
if %errorlevel% neq 0 exit /b %errorlevel%
@echo #######################################################_requirements_end
{'fraction_non_alphanumeric': 0.2152474364690147, 'fraction_numerical': 0.009629959875167187, 'mean_word_length': 6.943342776203966, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '403112', 'n_tokens_mistral': 4190, 'n_tokens_neox': 3977, 'n_words': 832}