예제 #1
0
파일: app.py 프로젝트: metatooling/checkon
def get_pull_requests(url: hyperlink.URL) -> t.List[str]:
    url = url.replace(host="api.github.com",
                      path=("repos", ) + url.path + ("pulls", ))

    r = requests.get(url)
    r.raise_for_status()
    pulls = r.json()
    out = []

    assert isinstance(pulls, list)
    for pull in pulls:

        head = pull["head"]
        if head is None:
            continue
        repo = head["repo"]
        if repo is None:
            continue
        clone_url = repo["clone_url"]

        ref = head["ref"]
        if clone_url is None or ref is None:
            continue
        out.append(f"git+{clone_url}@{ref}")
    return out
예제 #2
0
파일: sanitize.py 프로젝트: twm/yarrharr
 def _watch_url(self, embed_url):
     """
     Generate the URL of the YouTube page at which the embedded video can be
     viewed.
     """
     video_id = embed_url.path[1]
     watch_url = URL(
         scheme='https',
         host='www.youtube.com',
         path=('watch',),
         query=(('v', video_id),),
     )
     try:
         [start] = embed_url.get('start')
     except (KeyError, ValueError):
         return watch_url
     if not start.isdigit():
         return watch_url  # Ignore an invalid second offset.
     return watch_url.replace(fragment='t={}s'.format(start))
예제 #3
0
def _unprefix(url: URL) -> URL:
    prefix = URLs.app.path[:-1]
    assert url.path[:len(prefix)] == prefix, (url.path[len(prefix):], prefix)
    return url.replace(path=url.path[len(prefix):])
예제 #4
0
def _unprefix(url: URL) -> URL:
    prefix = URLs.api.path[:-1]
    assert url.path[:len(prefix)] == prefix, (url.path[len(prefix):], prefix)
    return url.replace(path=url.path[len(prefix):])