<commit_before>from __future__ import unicode_literals

import os

from . import helper



def readStatus(student):
    student = student.lower()

    path = helper.getConfigValue("settings", "attachment_path")

    if not os.path.exists(path):
        return

    path = os.path.join(path, student)

    if not os.path.exists(path):
        return "Student ohne Abgabe"

    path = os.path.join(path, "korrekturstatus.txt")

    if not os.path.exists(path):
        return "Unbearbeitet"
    statusfile = open(path, "r")
    status = statusfile.read()
    statusfile.close()
    return status


def writeStatus(student, status):
    student = student.lower()
    status = status.lower()

    path = os.path.join(helper.getConfigValue("settings", "attachment_path"), student)

    if not os.path.exists(path):
        logging.error("Requested student '%s' hasn't submitted anything yet.")
        return

    path = os.path.join(path, "korrekturstatus.txt")
    
    statusfile = open(path, "w")
    statusfile.write(status)
    statusfile.close()<commit_msg>Use open with<commit_after>from __future__ import unicode_literals

import os

from . import helper


def readStatus(student):
    student = student.lower()

    path = helper.getConfigValue("settings", "attachment_path")

    if not os.path.exists(path):
        return

    path = os.path.join(path, student)

    if not os.path.exists(path):
        return "Student ohne Abgabe"

    path = os.path.join(path, "korrekturstatus.txt")

    if not os.path.exists(path):
        return "Unbearbeitet"

    statusfile = open(path, "r")
    status = statusfile.read()
    statusfile.close()
    return status


def writeStatus(student, status):
    student = student.lower()
    status = status.lower()

    path = os.path.join(helper.getConfigValue("settings", "attachment_path"), student)

    if not os.path.exists(path):
        logging.error("Requested student '%s' hasn't submitted anything yet.")
        return

    path = os.path.join(path, "korrekturstatus.txt")

    with open(path, "w") as statusfile:
        statusfile.write(status)
{'fraction_non_alphanumeric': 0.12131303520456709, 'fraction_numerical': 0.0, 'mean_word_length': 3.156126482213439, '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': '4792846', 'n_tokens_mistral': 661, 'n_tokens_neox': 641, 'n_words': 154}