<commit_before># coding=utf-8
import sys
import datetime


class TeamcityServiceMessages(object):
    quote = {"'": "|'", "|": "||", "\n": "|n", "\r": "|r", ']': '|]'}

    def __init__(self, output=sys.stdout, now=datetime.datetime.now):
        self.output = output
        self.now = now

    def escapeValue(self, value):
        return "".join([self.quote.get(x, x) for x in value])

    def message(self, messageName, **properties):
        self.output.write("\n##teamcity[%s timestamp='%s'" % (messageName, self.now().strftime("%Y-%m-%dT%H:%M:%S.%f")[:-3]))
        for k in sorted(properties.keys()):
            value = properties[k]
            if value is None:
                continue

            self.output.write(" %s='%s'" % (k, self.escapeValue(value)))
        self.output.write("]\n")

        # Python may buffer it for a long time, flushing helps to see real-time result
        self.output.flush()

    def _single_value_message(self, messageName, value):
        self.output.write("\n##teamcity[%s '%s']\n" % (messageName, self.escapeValue(value)))
<commit_msg>do not use %f from strftime since it supported in 2.6+<commit_after># coding=utf-8
import sys
import datetime


class TeamcityServiceMessages(object):
    quote = {"'": "|'", "|": "||", "\n": "|n", "\r": "|r", ']': '|]'}

    def __init__(self, output=sys.stdout, now=datetime.datetime.now):
        self.output = output
        self.now = now

    def escapeValue(self, value):
        return "".join([self.quote.get(x, x) for x in value])

    def message(self, messageName, **properties):
        timestamp = self.now().strftime("%Y-%m-%dT%H:%M:%S.") + "%03d" % (self.now().microsecond / 1000)
        self.output.write("\n##teamcity[%s timestamp='%s'" % (messageName, timestamp))

        for k in sorted(properties.keys()):
            value = properties[k]
            if value is None:
                continue

            self.output.write(" %s='%s'" % (k, self.escapeValue(value)))
        self.output.write("]\n")

        # Python may buffer it for a long time, flushing helps to see real-time result
        self.output.flush()

    def _single_value_message(self, messageName, value):
        self.output.write("\n##teamcity[%s '%s']\n" % (messageName, self.escapeValue(value)))

{'fraction_non_alphanumeric': 0.18481123792800702, 'fraction_numerical': 0.004828797190517998, 'mean_word_length': 2.8627118644067795, 'pattern_counts': {'":': 8, '<': 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': '1316941', 'n_tokens_mistral': 750, 'n_tokens_neox': 723, 'n_words': 171}