<commit_before>#!/usr/bin/env python

import os, sys, shutil
import errno    
import subprocess
import zipfile


def zipdir(path, ziph):
    for root, dirs, files in os.walk(path):
        for file in files:
            ziph.write(os.path.join(root, file))

def mkdir(path):
    try:
        os.makedirs(path)
    except OSError as exc:  # Python >2.5
        if exc.errno == errno.EEXIST and os.path.isdir(path):
            pass
        else:
            raise

version = 'master'

if len(sys.argv) > 1:
    version = sys.argv[1]

release = "lamestation-sdk-"+version
archive = release+".zip"
builddir = ".build"

print release

try:
    shutil.rmtree(builddir)
except:
    pass
shutil.copytree("library",builddir)

def command(cmd):
    try:
        out = subprocess.check_output(cmd)
    except subprocess.CalledProcessError as e:
        print "Error: Command failed"
        sys.exit(1)
    return out


out = command(["git","ls-tree","-r",version,"--name-only"])

for line in out.splitlines():

    if not line.endswith(".spin"):  continue

    filebase = os.path.basename(line)

    if filebase.startswith('gfx'):  continue
    if filebase.startswith('map'):  continue<commit_msg>Purge unwanted files from SDK<commit_after>#!/usr/bin/env python

import os, sys, shutil
import errno    
import subprocess
import zipfile
import fnmatch
import re


def zipdir(path, ziph):
    for root, dirs, files in os.walk(path):
        for file in files:
            ziph.write(os.path.join(root, file))

def mkdir(path):
    try:
        os.makedirs(path)
    except OSError as exc:  # Python >2.5
        if exc.errno == errno.EEXIST and os.path.isdir(path):
            pass
        else:
            raise

def purge(directory, pattern):
    for root, dirnames, filenames in os.walk(directory):
        for filename in fnmatch.filter(filenames, pattern):
            print "del", os.path.join(root, filename)
            os.remove(os.path.join(root, filename))

version = 'master'

if len(sys.argv) > 1:
    version = sys.argv[1]

release = "lamestation-sdk-"+version
archive = release+".zip"
builddir = ".build"

print release

try:
    shutil.rmtree(builddir)
except:
    pass
shutil.copytree("library",builddir)

purge(builddir, "*.sh")
purge(builddir, "*.xcf")
purge(builddir, "*.svg")

def command(cmd):
    try:
        out = subprocess.check_output(cmd)
    except subprocess.CalledProcessError as e:
        print "Error: Command failed"
        sys.exit(1)
    return out


files = command(["git","ls-tree","-r",version,"--name-only"]).splitlines()
files = [f for f in files if re.match(r'.*\.spin', f)]

for line in files:
    filebase = os.path.basename(line)

    if filebase.startswith('gfx'):  continue
    if filebase.startswith('map'):  continue
{'fraction_non_alphanumeric': 0.13265675969554186, 'fraction_numerical': 0.003624501631025734, 'mean_word_length': 2.887323943661972, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '6393416', 'n_tokens_mistral': 951, 'n_tokens_neox': 931, 'n_words': 236}