(self, auth=False)
| 126 | |
| 127 | class GithubGet: |
| 128 | def __init__(self, auth=False): |
| 129 | self.headers = {'User-Agent': 'gh_lists.py', |
| 130 | 'Accept': 'application/vnd.github.v3+json'} |
| 131 | |
| 132 | if auth: |
| 133 | self.authenticate() |
| 134 | |
| 135 | req = self.urlopen('https://api.github.com/rate_limit') |
| 136 | try: |
| 137 | if req.getcode() != 200: |
| 138 | raise RuntimeError() |
| 139 | info = json.loads(req.read().decode('utf-8')) |
| 140 | finally: |
| 141 | req.close() |
| 142 | |
| 143 | self.ratelimit_remaining = int(info['rate']['remaining']) |
| 144 | self.ratelimit_reset = float(info['rate']['reset']) |
| 145 | |
| 146 | def authenticate(self): |
| 147 | print("Input a Github API access token.\n" |
nothing calls this directly
no test coverage detected