<commit_before>"""
Manages the read-eval-print loop
"""
from __future__ import unicode_literals, print_function
from prompt_toolkit import prompt
from prompt_toolkit.history import FileHistory
from prompt_toolkit.auto_suggest import AutoSuggestFromHistory
from pygments.lexers.matlab import MatlabLexer
from colorama import Fore, init

from lexer import Lexer
from parser import Parser
from errors import MatlabetteError
from context import Context
import os

init()
home = os.environ.get("HOME") or os.environ.get("USERPROFILE")
workspace, history = None, None
if home:
    matlabette_dir = os.path.join(home, '.matlabette')
    if not os.path.isdir(matlabette_dir):
        os.mkdir(matlabette_dir)
    if matlabette_dir:
        workspace = os.path.join(matlabette_dir, 'workspace')
        if workspace:
            open(workspace, 'w')
        history = os.path.join(matlabette_dir, 'history')
workspace_file = workspace or 'workspace'
history_file = history or 'history'


class Repl(object):
<commit_msg>Close workspace file after creating it<commit_after>"""
Manages the read-eval-print loop
"""
from __future__ import unicode_literals, print_function
from prompt_toolkit import prompt
from prompt_toolkit.history import FileHistory
from prompt_toolkit.auto_suggest import AutoSuggestFromHistory
from pygments.lexers.matlab import MatlabLexer
from colorama import Fore, init

from lexer import Lexer
from parser import Parser
from errors import MatlabetteError
from context import Context
import os

init()
home = os.environ.get("HOME") or os.environ.get("USERPROFILE")
workspace, history = None, None
if home:
    matlabette_dir = os.path.join(home, '.matlabette')
    if not os.path.isdir(matlabette_dir):
        os.mkdir(matlabette_dir)
    if matlabette_dir:
        workspace = os.path.join(matlabette_dir, 'workspace')
        if workspace:
            open(workspace, 'w').close()
        history = os.path.join(matlabette_dir, 'history')
workspace_file = workspace or 'workspace'
history_file = history or 'history'


class Repl(object):

{'fraction_non_alphanumeric': 0.08418491484184915, 'fraction_numerical': 0.0, 'mean_word_length': 4.695290858725762, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '1830368', 'n_tokens_mistral': 634, 'n_tokens_neox': 623, 'n_words': 183}