(repo, path, ref=None)
| 94 | |
| 95 | |
| 96 | def upstream_file(repo, path, ref=None): |
| 97 | url = f"repos/{repo}/contents/{path}" |
| 98 | if ref: |
| 99 | url += f"?ref={ref}" |
| 100 | out = gh_api(url) |
| 101 | if not out: |
| 102 | return None |
| 103 | try: |
| 104 | d = json.loads(out) |
| 105 | if isinstance(d, dict) and d.get("content"): |
| 106 | return base64.b64decode(d["content"]).decode("utf-8", "replace") |
| 107 | except Exception: |
| 108 | pass |
| 109 | return None |
| 110 | |
| 111 | |
| 112 | def local_license(dirpath): |
no test coverage detected