<commit_before>from buildbot.status.web.hooks.github import GitHubEventHandler
from twisted.python import log
import abconfig

class AutobuilderGithubEventHandler(GitHubEventHandler):

    def handle_push(self, payload):
        # This field is unused:
        user = None
        # user = payload['pusher']['name']
        repo = payload['repository']['name']
        repo_url = payload['repository']['url']
        # NOTE: what would be a reasonable value for project?
        # project = request.args.get('project', [''])[0]
        project = abconfig.get_project_for_url(repo_url,
                                               default_if_not_found=payload['repository']['full_name'])

        changes = self._process_change(payload, user, repo, repo_url, project)<commit_msg>Add a codebase generator to the Github web hoook handler, to map the URL to the repo name for use as the codebase.<commit_after>from buildbot.status.web.hooks.github import GitHubEventHandler
from twisted.python import log
import abconfig

def codebasemap(payload):
    return abconfig.get_project_for_url(payload['repository']['url'])

class AutobuilderGithubEventHandler(GitHubEventHandler):

    def __init__(self, secret, strict codebase=None):
        if codebase is None:
            codebase = codebasemap
        GitHubEventHandler.__init__(self, secret, strict, codebase)

    def handle_push(self, payload):
        # This field is unused:
        user = None
        # user = payload['pusher']['name']
        repo = payload['repository']['name']
        repo_url = payload['repository']['url']
        # NOTE: what would be a reasonable value for project?
        # project = request.args.get('project', [''])[0]
        project = abconfig.get_project_for_url(repo_url,
                                               default_if_not_found=payload['repository']['full_name'])

        changes = self._process_change(payload, user, repo, repo_url, project)
{'fraction_non_alphanumeric': 0.1038560411311054, 'fraction_numerical': 0.0010282776349614395, 'mean_word_length': 3.1404255319148935, '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': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1966748', 'n_tokens_mistral': 507, 'n_tokens_neox': 511, 'n_words': 136}