<commit_before>import subprocess
import sys
import os
import tarfile
import shutil

def generate(idl, lang, indir, outdir0):
    outdir = outdir0 + '/' + lang
    try: os.mkdir(outdir)
    except: pass
    print "generating %s.%s" % (idl, lang)
    idlfile = idl+".idl"
    options = []
    if lang == "cpp":
        options.append("-p")
        options.append("-n")
        options.append("jubatus")
    if lang == "ruby":
        options.append("-m")
        options.append("jubatus")
    if lang == "java":
        options.append("-p")
        options.append("jubatus")
    if lang == "haskell":
        os.mkdir(outdir+'/'+idl)
        outdir = outdir+'/'+idl

    cmd = ["mpidl", lang, indir+idlfile, '-o', outdir] + options
    print cmd
    subprocess.call(cmd)

def get_version(path):
    f = open(path + "wscript")
    for line in f.readlines():
        if line[:7] == 'VERSION':
            return line

def write_version(version_string, file):
    f = open(file, "w")
    f.write(version_string)
    f.close()

def pack(outdir):
    version_string = get_version("../")
    write_version(version_string, outdir+'/VERSION')

    tar = tarfile.open("jubatus-clients.tar.gz", "w:gz")
    tar.add(outdir)
    tar.close()

    shutil.rmtree(outdir, True)

if __name__=='__main__':
    indir = "../src/server/"
    if len(sys.argv) > 1:
        indir = sys.argv[1] + "/"
    outdir = "jubatus-clients"
    try: os.mkdir(outdir)
    except: pass
    langs = ["haskell", "cpp", "ruby", "java", "php", "perl", "python"]
    servers = ["classifier", "regression", "recommender", "stat"]
    comb = [ (s, l) for s in servers for l in langs ]
    map(lambda (x,y): generate(x,y, indir, outdir), comb)

    pack(outdir)<commit_msg>Fix ruby client generating bug and support Python 3.x<commit_after>import subprocess
import sys
import os
import tarfile
import shutil

def generate(idl, lang, indir, outdir0):
    outdir = outdir0 + '/' + lang
    try:
        os.mkdir(outdir)
    except:
        pass

    print("generating {0}.{1}".format(idl, lang))
    idlfile = idl+".idl"
    options = []
    if lang == "cpp":
        options.append("-p")
        options.append("-n")
        options.append("jubatus")
    if lang == "ruby":
        options.append("-m")
        options.append("Jubatus")
    if lang == "java":
        options.append("-p")
        options.append("jubatus")
    if lang == "haskell":
        try:
            os.mkdir(outdir + '/' + idl)
        except:
            pass
        outdir = outdir + '/' + idl

    cmd = ["mpidl", lang, indir + idlfile, '-o', outdir] + options
    print(cmd)
    subprocess.call(cmd)

def get_version(path):
    f = open(path + "wscript")
    for line in f.readlines():
        if line[:7] == 'VERSION':
            return line

def write_version(version_string, file):
    f = open(file, "w")
    f.write(version_string)
    f.close()

def pack(outdir):
    version_string = get_version("../")
    write_version(version_string, outdir + '/VERSION')

    tar = tarfile.open("jubatus-clients.tar.gz", "w:gz")
    tar.add(outdir)
    tar.close()

    shutil.rmtree(outdir, True)

if __name__=='__main__':
    indir = "../src/server/"
    if len(sys.argv) > 1:
        indir = sys.argv[1] + "/"
    outdir = "jubatus-clients"
    try: os.mkdir(outdir)
    except: pass
    langs = ["haskell", "cpp", "ruby", "java", "php", "perl", "python"]
    servers = ["classifier", "regression", "recommender", "stat"]
    comb = [(s, l) for s in servers for l in langs]
    for x, y in comb:
        generate(x,y, indir, outdir)

    pack(outdir)
{'fraction_non_alphanumeric': 0.16694584031267448, 'fraction_numerical': 0.0036292573981016193, 'mean_word_length': 2.5651741293532337, 'pattern_counts': {'":': 8, '<': 3, '<?xml version=': 0, '>': 5, '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': '3594986', 'n_tokens_mistral': 1295, 'n_tokens_neox': 1270, 'n_words': 299}