How to use the gidgethub.sansio.format_url 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 / bedevere / tests / test_backport.py View on Github external
async def post(self, url, url_vars={}, *, data):
        post_url = sansio.format_url(url, url_vars)
        self.post_.append((post_url, data))
github python / bedevere / tests / test_follow_up.py View on Github external
async def post(self, url, url_vars={}, *, data):
        self.post_url = sansio.format_url(url, url_vars)
        self.post_data = data
github python / bedevere / tests / test_stage.py View on Github external
async def getitem(self, url, url_vars={}):
        self.getitem_url = sansio.format_url(url, url_vars)
        to_return = self._getitem_return[self.getitem_url]
        if isinstance(to_return, Exception):
            raise to_return
        else:
            return to_return
github python / bedevere / tests / test_stage.py View on Github external
async def delete(self, url, url_vars={}):
        self.delete_url = sansio.format_url(url, url_vars)
github python / bedevere / tests / test_stage.py View on Github external
async def getiter(self, url, url_vars={}):
        self.getiter_url = sansio.format_url(url, url_vars)
        to_iterate = self._getiter_return[self.getiter_url]
        for item in to_iterate:
            yield item
github python / bedevere / tests / test_stage.py View on Github external
async def post(self, url, url_vars={}, *, data):
        post_url = sansio.format_url(url, url_vars)
        self.post_.append((post_url, data))
github bioconda / bioconda-utils / bioconda_utils / githubhandler.py View on Github external
This is a hack. The card data returned from github does not contain
        content_id or anything referencing the PR/issue except for the
        content_url. We deparse this here manually.

        Arguments:
          card: Card dict as returned from github
        Results:
          Card dict with ``issue_number`` field added if card is not a note
        """
        if 'content_url' not in card:  # not content_url to parse
            return card
        if 'issue_number' in card:  # target value already taken
            return card

        issue_url = gidgethub.sansio.format_url(self.ISSUES, self.var_default)
        content_url = card['content_url']
        if content_url.startswith(issue_url):
            try:
                card['issue_number'] = int(content_url.lstrip(issue_url))
            except ValueError:
                pass
        if 'issue_number' not in card:
            logger.error("Failed to deparse content url to issue number.\n"
                         "content_url=%s\nissue_url=%s\n",
                         content_url, issue_url)
        return card
github brettcannon / gidgethub / gidgethub / abc.py View on Github external
async def _make_request(self, method: str, url: str, url_vars: Dict[str, str],
                            data: Any, accept: str,
                            jwt: Opt[str] = None,
                            oauth_token: Opt[str] = None,
                            ) -> Tuple[bytes, Opt[str]]:
        """Construct and make an HTTP request."""
        if oauth_token is not None and jwt is not None:
            raise ValueError("Cannot pass both oauth_token and jwt.")
        filled_url = sansio.format_url(url, url_vars)
        if jwt is not None:
            request_headers = sansio.create_headers(
                self.requester, accept=accept,
                jwt=jwt)
        elif oauth_token is not None:
            request_headers = sansio.create_headers(
                self.requester, accept=accept,
                oauth_token=oauth_token)
        else:
            # fallback to using oauth_token
            request_headers = sansio.create_headers(
                self.requester, accept=accept,
                oauth_token=self.oauth_token)
        cached = cacheable = False
        # Can't use None as a "no body" sentinel as it's a legitimate JSON type.
        if data == b"":