<commit_before>import logging

log = logging.getLogger(__name__)


class Reporter(object):
    def report_line(self, repo_name, commit, file_name, line_number, position, message):
        raise NotImplementedError()


class PrintingReporter(Reporter):
    def report_line(self, repo_name, commit, file_name, line_number, position, message):
        print "Would have posted the following: \n" \
          "commit: %(commit)s\n" \
          "position: %(position)s\n" \
          "message: %(message)s\n" \
          "file: %(filename)s\n" \
          "repo: %(repo)s\n" % {
              'repo': repo_name,
              'commit': commit,
              'position': position,
              'message': message,
              'filename': file_name
          }


class CommitReporter(Reporter):
    def __init__(self, requester):
        self.requester = requester

    def report_line(self, repo_name, commit, file_name, line_number, position, message):
        payload = {
            'body': message,
            'sha': commit,
            'path': file_name,
            'position': position,
            'line': None,
        }
        self.requester.post(
            'https://api.github.com/repos/%s/commits/%s/comments' % (repo_name, commit),
            payload)


class PRReporter(Reporter):
    def __init__(self, requester, pr_number):
        self.requester = requester
        self.pr_number = pr_number

    def report_line(self, repo_name, commit, file_name, line_number, position, message):
        payload = {
            'body': message,
            'commit_id': commit, # sha
            'path': file_name, # relative file path
            'position': position, # line index into the diff
        }

        result = self.requester.post(
            'https://api.github.com/repos/%s/pulls/%s/comments' % (repo_name, self.pr_number),
            payload)
        if result.status_code >= 400:
            log.error("Error posting line to github. %s", result.json)
        return result<commit_msg>Pushing broken logging changes, to show someone.<commit_after>import logging

log = logging.getLogger(__name__)


class Reporter(object):
    def report_line(self, repo_name, commit, file_name, line_number, position, message):
        raise NotImplementedError()


class PrintingReporter(Reporter):
    def report_line(self, repo_name, commit, file_name, line_number, position, message):
        log.debug('WARNING')
        print "Would have posted the following: \n" \
          "commit: %(commit)s\n" \
          "position: %(position)s\n" \
          "message: %(message)s\n" \
          "file: %(filename)s\n" \
          "repo: %(repo)s\n" % {
              'repo': repo_name,
              'commit': commit,
              'position': position,
              'message': message,
              'filename': file_name
          }


class CommitReporter(Reporter):
    def __init__(self, requester):
        self.requester = requester

    def report_line(self, repo_name, commit, file_name, line_number, position, message):
        payload = {
            'body': message,
            'sha': commit,
            'path': file_name,
            'position': position,
            'line': None,
        }
        request = 'https://api.github.com/repos/%s/commits/%s/comments' % (repo_name, commit)
        log.debug("Commit Request: %s", request)
        log.debug("Commit Payload: %s", payload)
        self.requester.post(request, payload)


class PRReporter(Reporter):
    def __init__(self, requester, pr_number):
        self.requester = requester
        self.pr_number = pr_number

    def report_line(self, repo_name, commit, file_name, line_number, position, message):
        payload = {
            'body': message,
            'commit_id': commit, # sha
            'path': file_name, # relative file path
            'position': position, # line index into the diff
        }
        request = 'https://api.github.com/repos/%s/pulls/%s/comments' % (repo_name, self.pr_number)
        log.debug("PR request: %s", request)
        log.debug("PR payload: %s", payload)
        result = self.requester.post(request, payload)
        if result.status_code >= 400:
            log.error("Error posting line to github. %s", result.json)
        return result
{'fraction_non_alphanumeric': 0.12374269005847953, 'fraction_numerical': 0.0014035087719298245, 'mean_word_length': 2.2271698113207545, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 4, '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': '3668767', 'n_tokens_mistral': 1263, 'n_tokens_neox': 1237, 'n_words': 300}