<commit_before>import oct2py
import os
import re
import requests
import StringIO
import zipfile
import tempfile
import shutil

from flask import Flask, render_template, request, jsonify
#from flask_socketio import SocketIO, emit

app = Flask(__name__)

app.config['DEBUG'] = True
app.config['APPDIR'] = os.path.dirname(os.path.realpath(__file__))
app.config['MATL_FOLDER'] = os.path.join(app.config['APPDIR'], 'MATL')
app.config['MATL_REPO'] = 'lmendo/MATL'
app.config['MATL_WRAP_DIR'] = os.path.join(app.config['MATL_FOLDER'], 'wrappers')
app.config['GITHUB_API'] = 'https://api.github.com'

#socketio = SocketIO(app)

oc = oct2py.Oct2Py()

# Add all of our custom and overloaded functions on the path
oc.addpath(app.config['MATL_WRAP_DIR'])
oc.source(os.path.join(app.config['MATL_WRAP_DIR'], '.octaverc'))


def get_members(zip_file):
    """
    Removes leading directory from all contents of the zip file
    """
    prefix = os.path.commonprefix(zip_file.namelist())

    offset = len(prefix)

    for zip_info in zip_file.infolist():
        name = zip_info.filename
        if len(name) > offset:
            zip_info.filename = name[offset:]
            yield zip_info


def install_matl(version, folder):

    url = app.config['GITHUB_API'] + '/repos/' + app.config['MATL_REPO'] + '/releases/tags/' + version
    resp = requests.get(url)

    if resp.status_code == 404:
        raise KeyError('Tag "%s" is invalid' % version)
<commit_msg>Swaps the order of path additions to prevent issues<commit_after>import oct2py
import os
import re
import requests
import StringIO
import zipfile
import tempfile
import shutil

from flask import Flask, render_template, request, jsonify
#from flask_socketio import SocketIO, emit

app = Flask(__name__)

app.config['DEBUG'] = True
app.config['APPDIR'] = os.path.dirname(os.path.realpath(__file__))
app.config['MATL_FOLDER'] = os.path.join(app.config['APPDIR'], 'MATL')
app.config['MATL_REPO'] = 'lmendo/MATL'
app.config['MATL_WRAP_DIR'] = os.path.join(app.config['MATL_FOLDER'], 'wrappers')
app.config['GITHUB_API'] = 'https://api.github.com'

#socketio = SocketIO(app)

oc = oct2py.Oct2Py()

# Add all of our custom and overloaded functions on the path
oc.source(os.path.join(app.config['MATL_WRAP_DIR'], '.octaverc'))
oc.addpath(app.config['MATL_WRAP_DIR'])


def get_members(zip_file):
    """
    Removes leading directory from all contents of the zip file
    """
    prefix = os.path.commonprefix(zip_file.namelist())

    offset = len(prefix)

    for zip_info in zip_file.infolist():
        name = zip_info.filename
        if len(name) > offset:
            zip_info.filename = name[offset:]
            yield zip_info


def install_matl(version, folder):

    url = app.config['GITHUB_API'] + '/repos/' + app.config['MATL_REPO'] + '/releases/tags/' + version
    resp = requests.get(url)

    if resp.status_code == 404:
        raise KeyError('Tag "%s" is invalid' % version)

{'fraction_non_alphanumeric': 0.1369209809264305, 'fraction_numerical': 0.004087193460490463, 'mean_word_length': 4.198230088495575, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 2, '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': '3640497', 'n_tokens_mistral': 1033, 'n_tokens_neox': 1005, 'n_words': 230}