<commit_before>import logging
import time
from datetime import datetime
import types

from .micromodels.fields import ModelCollectionField
from . import SlickConnection, SlickCommunicationError, Release, Build, BuildReference, Component, ComponentReference, \
    Project, Testplan, Testrun, Testcase, RunStatus, Result, ResultStatus, LogEntry, Configuration, TestrunGroup, TestrunReference


def add_log_entry(self, message, level='DEBUG', loggername='', exceptionclassname='', exceptionmessage='', stacktrace=''):
    entry = LogEntry()
    entry.entryTime = int(round(time.time() * 1000))
    entry.message = message
    entry.level = level
    entry.loggerName = loggername
    entry.exceptionClassName = exceptionclassname
    entry.exceptionMessage = exceptionmessage
    entry.exceptionStackTrace = stacktrace
    if not hasattr(self, 'log'):
        self.log = []
    self.log.append(entry)

def update_result(self):
    self.connection.results(self).update()

def update_testrun(self):
    self.connection.testrun(self).update()

def add_file_to_result(self, filename, fileobj=None):
    slickfile = self.connection.files.upload_local_file(filename, fileobj)
    if not hasattr(self, 'files'):
        self.files = []
    self.files.append(slickfile)
    self.update()

def make_result_updatable(result, connection):
    result.connection = connection<commit_msg>typo in update_testrun<commit_after>import logging
import time
from datetime import datetime
import types

from .micromodels.fields import ModelCollectionField
from . import SlickConnection, SlickCommunicationError, Release, Build, BuildReference, Component, ComponentReference, \
    Project, Testplan, Testrun, Testcase, RunStatus, Result, ResultStatus, LogEntry, Configuration, TestrunGroup, TestrunReference


def add_log_entry(self, message, level='DEBUG', loggername='', exceptionclassname='', exceptionmessage='', stacktrace=''):
    entry = LogEntry()
    entry.entryTime = int(round(time.time() * 1000))
    entry.message = message
    entry.level = level
    entry.loggerName = loggername
    entry.exceptionClassName = exceptionclassname
    entry.exceptionMessage = exceptionmessage
    entry.exceptionStackTrace = stacktrace
    if not hasattr(self, 'log'):
        self.log = []
    self.log.append(entry)

def update_result(self):
    self.connection.results(self).update()

def update_testrun(self):
    self.connection.testruns(self).update()

def add_file_to_result(self, filename, fileobj=None):
    slickfile = self.connection.files.upload_local_file(filename, fileobj)
    if not hasattr(self, 'files'):
        self.files = []
    self.files.append(slickfile)
    self.update()

def make_result_updatable(result, connection):
    result.connection = connection
{'fraction_non_alphanumeric': 0.10384894698620188, 'fraction_numerical': 0.002904865649963689, 'mean_word_length': 4.950323974082074, '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': '3697526', 'n_tokens_mistral': 780, 'n_tokens_neox': 765, 'n_words': 181}