How to use the gidgethub.routing.Router function in gidgethub

To help you get started, we’ve selected a few gidgethub examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github python / miss-islington / miss_islington / __main__.py View on Github external
import sys
import traceback
import cachetools

from aiohttp import web

from gidgethub import aiohttp as gh_aiohttp
from gidgethub import routing
from gidgethub import sansio


from . import backport_pr
from . import delete_branch
from . import status_change

router = routing.Router(backport_pr.router, delete_branch.router, status_change.router)

cache = cachetools.LRUCache(maxsize=500)

import sentry_sdk

sentry_sdk.init(os.environ.get("SENTRY_DSN"))


async def main(request):
    try:
        body = await request.read()

        secret = os.environ.get("GH_SECRET")
        event = sansio.Event.from_http(request.headers, body, secret=secret)
        print("GH delivery ID", event.delivery_id, file=sys.stderr)
        if event.event == "ping":
github python / bedevere / bedevere / backport.py View on Github external
"""Automatically remove a backport label, and check backport PR validity."""
import functools
import re

import gidgethub.routing

from . import util

create_status = functools.partial(util.create_status, 'bedevere/maintenance-branch-pr')


router = gidgethub.routing.Router()

TITLE_RE = re.compile(r'\s*\[(?P\d+\.\d+)\].+\((?:GH-|#)(?P\d+)\)')
MAINTENANCE_BRANCH_TITLE_RE = re.compile(r'\s*\[(?P\d+\.\d+)\].+')
MAINTENANCE_BRANCH_RE = re.compile(r'\s*(?P\d+\.\d+)')
BACKPORT_LABEL = 'needs backport to {branch}'
MESSAGE_TEMPLATE = ('[GH-{pr}](https://github.com/python/cpython/pull/{pr}) is '
                    'a backport of this pull request to the '
                    '[{branch} branch](https://github.com/python/cpython/tree/{branch}).')


BACKPORT_TITLE_DEVGUIDE_URL = "https://devguide.python.org/committing/#backport-pr-title"

async def _copy_over_labels(gh, original_issue, backport_issue):
    """Copy over relevant labels from the original PR to the backport PR."""
    label_prefixes = "skip", "type", "sprint"
    labels = list(filter(lambda x: x.startswith(label_prefixes),