<commit_before>from collections import OrderedDict
import logging

log = logging.getLogger(__name__)


class IssueComment(object):
    """
    A simple comment that will be published as a
    pull request/issue comment.
    """
    filename = None
    # TODO remove line it is not really needed
    line = 0
    position = 0
    body = None

    def __init__(self, body=''):
        self.body = body

    def publish(self, repo, pull_request):
        log.debug("Publishing issue comment '%s'", self.body)
        try:
            pull_request.create_comment(self.body)
        except:
            log.warn("Failed to save comment '%s'", self.body)

    def key(self):
        return (self.filename, self.position)

    def append_body(self, text):
        if text not in self.body:
            self.body += "\n" + text

    def __eq__(self, other):
        """
        Overload eq to make testing much simpler.
        """
        return (self.filename == other.filename and
                self.position == other.position and
                self.body == other.body)

    def __repr__(self):
        return "%s(filename=%s, line=%s, position=%s, body=%s)" % (
            str(self.__class__.__name__),
            self.filename,
            self.line,
            self.position,
            self.body)
<commit_msg>Log more information when comments fail to save.<commit_after>from collections import OrderedDict
import logging

log = logging.getLogger(__name__)


class IssueComment(object):
    """
    A simple comment that will be published as a
    pull request/issue comment.
    """
    filename = None
    # TODO remove line it is not really needed
    line = 0
    position = 0
    body = None

    def __init__(self, body=''):
        self.body = body

    def publish(self, repo, pull_request):
        log.debug("Publishing issue comment '%s'", self.body)
        try:
            pull_request.create_comment(self.body)
        except Exception as e:
            log.warn("Failed to save comment. body='%s' error=%s",
                     self.body,
                     e.message)

    def key(self):
        return (self.filename, self.position)

    def append_body(self, text):
        if text not in self.body:
            self.body += "\n" + text

    def __eq__(self, other):
        """
        Overload eq to make testing much simpler.
        """
        return (self.filename == other.filename and
                self.position == other.position and
                self.body == other.body)

    def __repr__(self):
        return "%s(filename=%s, line=%s, position=%s, body=%s)" % (
            str(self.__class__.__name__),
            self.filename,
            self.line,
            self.position,
            self.body)

{'fraction_non_alphanumeric': 0.10654545454545454, 'fraction_numerical': 0.0014545454545454545, 'mean_word_length': 1.939102564102564, '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': '617786', 'n_tokens_mistral': 770, 'n_tokens_neox': 746, 'n_words': 228}