<commit_before>"""-------------------------------------------------
Satay Game Engine Copyright (C) 2012 <NAME>

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

Satay on GitHub: https://github.com/Valdez42/Satay

 CreateWinEXE.py --
   Utility script to create a Windows executable from
   a main Satay game script. Uses py2exe for creation.
   This is a Windows-only utility.
-------------------------------------------------"""

import sys
import os
import webbrowser
import subprocess
import urllib2
import shutil
from zipfile import ZipFile

def CreatePromptCheck(*answers):
    return lambda prompt: raw_input(prompt).lower() in answers

Y = CreatePromptCheck('y', 'ye', 'yes')
N = CreatePromptCheck('n', 'no')

setup = """
# Auto-generated by Satay.Utilities.CreateWinEXE
from distutils.core import setup
import py2exe
import os

os.chdir(%r)
setup(
    console=[
        {
            "script":%r,
        }
    ]
)
"""

# Ensure the user has py2exe
try:
    import py2exe
except ImportError:
    print("You do not have py2exe installed.")
    if Y("Download py2exe? (y for yes): "):
        print("Choose the correct installer based on your python bit-type and version.")
        print("Once downloaded, run the installer, and then re-run this utility.")
        webbrowser.open("http://www.lfd.uci.edu/~gohlke/pythonlibs/#py2exe")
        sys.exit()
    else:
        print("You need py2exe to use this utility.")
        sys.exit()
else:
    print("py2exe exists, continuing.")

# Gather script location info
sdir = raw_input("Now point us to your main game script's folder (rel. or absolute dir):\n")
script = raw_input("What is the name of your game script? (e.g. agame.py):\n")
if Y("Do you have an icon to embed into your executable? (y for yes): "):
    icon = raw_input("What is the name of your .ico file?\n")
    iloc = setup.find('"script":%r,')
    setup = setup[0:iloc] + ' "icon_resources": [(0, %r)], ' % icon + setup[iloc:]

# Change CWD
os.chdir(sdir)
print('Changed working directory to "%s" ' % os.getcwd())

# Create the setup script
with open("setup_py2exe.py","w") as setupScript:
    setupScript.write(setup % (os.getcwd(), script))
print("Setup script created. Now running setup_py2exe.py...")

# Derive python path from os.__file__
dpos1 = os.__file__.rfind("\\")
dpos2 = os.__file__.rfind("\\", 0, dpos1 - 1)
pydir = os.__file__[0:dpos2+1]+"python.exe"

# Execute py2exe script
xcode = subprocess.call([pydir, os.getcwd()+"\\setup_py2exe.py", "py2exe"])

# Evaluate script's exit code, and remove script.
if Y("Cleanup unnecessary files? (y for yes): "):
    os.remove("./setup_py2exe.py")
    shutil.rmtree("./build")

if xcode == 0:
    print("Satay game built successfully.")
    print("The 'dist' folder in your game's directory contains your built program.")
    if Y("Do you need the MSCV90 DLL distro? (y for yes): "):
        print("Downloading and extracting the distro package to your dist directory...")
        request = urllib2.Request("http://www.fileden.com/files/2012/11/23/3369670/MSVC90_distro.zip")
        request.add_header('User-Agent','Mozilla/5.0 (Windows NT 6.0; WOW64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.64 Safari/537.11')
        with open("MSVC90_distro.zip", 'wb') as f:
            f.write(urllib2.urlopen(request).read())
        with ZipFile("MSVC90_distro.zip", 'r') as z:
            z.extractall("./dist")
        if Y("Cleanup .zip package? (y for yes): "):
            os.remove("./MSVC90_distro.zip")
    print("Your game is ready to distribute! Ensure you give people the entire 'dist' directory!")
    sys.exit()
else:
    print("py2exe failed with exit code %s" % xcode)
    sys.exit()<commit_msg>Changed typo in CreateWinEXE script.<commit_after>"""-------------------------------------------------
Satay Game Engine Copyright (C) 2012 <NAME>

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

Satay on GitHub: https://github.com/Valdez42/Satay

 CreateWinEXE.py --
   Utility script to create a Windows executable from
   a main Satay game script. Uses py2exe for creation.
   This is a Windows-only utility.
-------------------------------------------------"""

import sys
import os
import webbrowser
import subprocess
import urllib2
import shutil
from zipfile import ZipFile

def CreatePromptCheck(*answers):
    return lambda prompt: raw_input(prompt).lower() in answers

Y = CreatePromptCheck('y', 'ye', 'yes')
N = CreatePromptCheck('n', 'no')

setup = """
# Auto-generated by Satay.Utilities.CreateWinEXE
from distutils.core import setup
import py2exe
import os

os.chdir(%r)
setup(
    console=[
        {
            "script":%r,
        }
    ]
)
"""

# Ensure the user has py2exe
try:
    import py2exe
except ImportError:
    print("You do not have py2exe installed.")
    if Y("Download py2exe? (y for yes): "):
        print("Choose the correct installer based on your python bit-type and version.")
        print("Once downloaded, run the installer, and then re-run this utility.")
        webbrowser.open("http://www.lfd.uci.edu/~gohlke/pythonlibs/#py2exe")
        sys.exit()
    else:
        print("You need py2exe to use this utility.")
        sys.exit()
else:
    print("py2exe exists, continuing.")

# Gather script location info
sdir = raw_input("Now point us to your main game script's folder (rel. or absolute dir):\n")
script = raw_input("What is the name of your game script? (e.g. agame.py):\n")
if Y("Do you have an icon to embed into your executable? (y for yes): "):
    icon = raw_input("What is the name of your .ico file?\n")
    iloc = setup.find('"script":%r,')
    setup = setup[0:iloc] + ' "icon_resources": [(0, %r)], ' % icon + setup[iloc:]

# Change CWD
os.chdir(sdir)
print('Changed working directory to "%s" ' % os.getcwd())

# Create the setup script
with open("setup_py2exe.py","w") as setupScript:
    setupScript.write(setup % (os.getcwd(), script))
print("Setup script created. Now running setup_py2exe.py...")

# Derive python path from os.__file__
dpos1 = os.__file__.rfind("\\")
dpos2 = os.__file__.rfind("\\", 0, dpos1 - 1)
pydir = os.__file__[0:dpos2+1]+"python.exe"

# Execute py2exe script
xcode = subprocess.call([pydir, os.getcwd()+"\\setup_py2exe.py", "py2exe"])

# Evaluate script's exit code, and remove script.
if Y("Cleanup unnecessary files? (y for yes): "):
    os.remove("./setup_py2exe.py")
    shutil.rmtree("./build")

if xcode == 0:
    print("Satay game built successfully.")
    print("The 'dist' folder in your game's directory contains your built program.")
    if Y("Do you need the MSVC90 DLL distro? (y for yes): "):
        print("Downloading and extracting the distro package to your dist directory...")
        request = urllib2.Request("http://www.fileden.com/files/2012/11/23/3369670/MSVC90_distro.zip")
        request.add_header('User-Agent','Mozilla/5.0 (Windows NT 6.0; WOW64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.64 Safari/537.11')
        with open("MSVC90_distro.zip", 'wb') as f:
            f.write(urllib2.urlopen(request).read())
        with ZipFile("MSVC90_distro.zip", 'r') as z:
            z.extractall("./dist")
        if Y("Cleanup .zip package? (y for yes): "):
            os.remove("./MSVC90_distro.zip")
    print("Your game is ready for distrobution! Ensure you give people the entire 'dist' directory!")
    sys.exit()
else:
    print("py2exe failed with exit code %s" % xcode)
    sys.exit()
{'fraction_non_alphanumeric': 0.14817961165048543, 'fraction_numerical': 0.02087378640776699, 'mean_word_length': 3.21319018404908, 'pattern_counts': {'":': 6, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3493591', 'n_tokens_mistral': 2769, 'n_tokens_neox': 2584, 'n_words': 875}