We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
GitHub: Show correct count of unread notifications
If you have more than 50 unread notifications in total, and you want to see that total notification count, the GitHub module still only shows 50 due to pagination:

https://github.com/ultrabug/py3status/blob/master/py3status/modules/github.py#L155

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `py3status/modules/github.py`
Content:
```
1 # -*- coding: utf-8 -*-
2 """
3 Display Github notifications and issue/pull requests for a repo.
4 
5 To check notifications a Github `username` and `personal access token` are
6 required.  You can create a personal access token at
7 https://github.com/settings/tokens The only `scope` needed is `notifications`,
8 which provides readonly access to notifications.
9 
10 The Github API is rate limited so setting `cache_timeout` too small may cause
11 issues see https://developer.github.com/v3/#rate-limiting for details
12 
13 Configuration parameters:
14     auth_token: Github personal access token, needed to check notifications
15         see above.
16         (default None)
17     button_action: Button that when clicked opens the Github notification page
18         if notifications, else the project page for the repository if there is
19         one (otherwise the github home page). Setting to `None` disables.
20         (default 3)
21     button_refresh: Button that when clicked refreshes module.
22         Setting to `None` disables.
23         (default 2)
24     cache_timeout: How often we refresh this module in seconds
25         (default 60)
26     format: Format of output
27         *(default '{repo} {issues}/{pull_requests}{notifications}'
28         if username and auth_token provided else
29         '{repo} {issues}/{pull_requests}')*
30     format_notifications: Format of `{notification}` status placeholder.
31         (default ' N{notifications_count}')
32     notifications: Type of notifications can be `all` for all notifications or
33         `repo` to only get notifications for the repo specified.  If repo is
34         not provided then all notifications will be checked.
35         (default 'all')
36     repo: Github repo to check
37         (default 'ultrabug/py3status')
38     username: Github username, needed to check notifications.
39         (default None)
40 
41 Format placeholders:
42     {issues} Number of open issues.
43     {notifications} Notifications.  If no notifications this will be empty.
44     {notifications_count} Number of notifications.  This is also the __Only__
45         placeholder available to `format_notifications`.
46     {pull_requests} Number of open pull requests
47     {repo} short name of the repository being checked. eg py3status
48     {repo_full} full name of the repository being checked. eg ultrabug/py3status
49 
50 Examples:
51 ```
52 # set github access credentials
53 github {
54     auth_token = '40_char_hex_access_token'
55     username = 'my_username'
56 }
57 
58 # just check for any notifications
59 github {
60     auth_token = '40_char_hex_access_token'
61     username = 'my_username'
62     format = 'Github {notifications_count}'
63 }
64 ```
65 
66 @author tobes
67 
68 SAMPLE OUTPUT
69 {'full_text': 'py3status 34/24'}
70 
71 notification
72 {'full_text': 'py3status 34/24 N3', 'urgent': True}
73 """
74 
75 GITHUB_API_URL = 'https://api.github.com'
76 GITHUB_URL = 'https://github.com/'
77 
78 
79 class Py3status:
80     auth_token = None
81     button_action = 3
82     button_refresh = 2
83     cache_timeout = 60
84     format = None
85     format_notifications = ' N{notifications_count}'
86     notifications = 'all'
87     repo = 'ultrabug/py3status'
88     username = None
89 
90     def post_config_hook(self):
91         self.first = True
92         self.notification_warning = False
93         self.repo_warning = False
94         self._issues = '?'
95         self._pulls = '?'
96         self._notify = '?'
97 
98     def _init(self):
99         # Set format if user has not configured it.
100         if not self.format:
101             if self.username and self.auth_token:
102                 # include notifications
103                 self.format = '{repo} {issues}/{pull_requests}{notifications}'
104             else:
105                 self.format = '{repo} {issues}/{pull_requests}'
106 
107     def _github_count(self, url):
108         """
109         Get counts for requests that return 'total_count' in the json response.
110         """
111         if self.first:
112             return '?'
113         url = GITHUB_API_URL + url + '&per_page=1'
114         # if we have authentication details use them as we get better
115         # rate-limiting.
116         if self.username and self.auth_token:
117             auth = (self.username, self.auth_token)
118         else:
119             auth = None
120         try:
121             info = self.py3.request(url, timeout=10, auth=auth)
122         except (self.py3.RequestException):
123             return
124         if info and info.status_code == 200:
125             return(int(info.json()['total_count']))
126         if info.status_code == 422:
127             if not self.repo_warning:
128                 self.py3.notify_user('Github repo cannot be found.')
129                 self.repo_warning = True
130         return '?'
131 
132     def _notifications(self):
133         """
134         Get the number of unread notifications.
135         """
136         if not self.username or not self.auth_token:
137             if not self.notification_warning:
138                 self.py3.notify_user('Github module needs username and '
139                                      'auth_token to check notifications.')
140                 self.notification_warning = True
141             return '?'
142         if self.first:
143             return '?'
144         if self.notifications == 'all' or not self.repo:
145             url = GITHUB_API_URL + '/notifications'
146         else:
147             url = GITHUB_API_URL + '/repos/' + self.repo + '/notifications'
148         url += '?per_page=100'
149         try:
150             info = self.py3.request(url, timeout=10,
151                                     auth=(self.username, self.auth_token))
152         except (self.py3.RequestException):
153             return
154         if info.status_code == 200:
155             return len(info.json())
156         if info.status_code == 404:
157             if not self.repo_warning:
158                 self.py3.notify_user('Github repo cannot be found.')
159                 self.repo_warning = True
160 
161     def github(self):
162         if self.first:
163             self._init()
164         status = {}
165         urgent = False
166         # issues
167         if self.repo and self.py3.format_contains(self.format, 'issues'):
168             url = '/search/issues?q=state:open+type:issue+repo:' + self.repo
169             self._issues = self._github_count(url) or self._issues
170         status['issues'] = self._issues
171         # pull requests
172         if self.repo and self.py3.format_contains(self.format, 'pull_requests'):
173             url = '/search/issues?q=state:open+type:pr+repo:' + self.repo
174             self._pulls = self._github_count(url) or self._pulls
175         status['pull_requests'] = self._pulls
176         # notifications
177         if (self.py3.format_contains(self.format, 'notifications') or
178                 self.py3.format_contains(self.format, 'notifications_count')):
179             count = self._notifications()
180             # if we don't have a notification count, then use the last value
181             # that we did have.
182             if count is None:
183                 count = self._notify
184             self._notify = count
185             if count and count != '?':
186                 notify = self.py3.safe_format(
187                     self.format_notifications,
188                     {'notifications_count': count})
189                 urgent = True
190             else:
191                 notify = ''
192             status['notifications'] = notify
193             status['notifications_count'] = count
194         # repo
195         try:
196             status['repo'] = self.repo.split('/')[1]
197         except IndexError:
198             status['repo'] = 'Error'
199         status['repo_full'] = self.repo
200 
201         if self.first:
202             cached_until = 0
203             self.first = False
204         else:
205             cached_until = self.py3.time_in(self.cache_timeout)
206 
207         return {
208             'full_text': self.py3.safe_format(self.format, status),
209             'cached_until': cached_until,
210             'urgent': urgent
211         }
212 
213     def on_click(self, event):
214         button = event['button']
215         if button == self.button_action:
216             # open github in browser
217             if self._notify and self._notify != '?':
218                 # open github notifications page
219                 url = GITHUB_URL + 'notifications'
220             else:
221                 if self.notifications == 'all' and not self.repo:
222                     # open github.com if there are no unread notifications and no repo
223                     url = GITHUB_URL
224                 else:
225                     # open repo page if there are no unread notifications
226                     url = GITHUB_URL + self.repo
227             # open url in default browser
228             self.py3.command_run('xdg-open {}'.format(url))
229             self.py3.prevent_refresh()
230         elif button != self.button_refresh:
231             # only refresh the module if needed
232             self.py3.prevent_refresh()
233 
234 
235 if __name__ == "__main__":
236     """
237     Run module in test mode.
238     """
239     from py3status.module_test import module_test
240     module_test(Py3status)
241
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/py3status/modules/github.py b/py3status/modules/github.py
--- a/py3status/modules/github.py
+++ b/py3status/modules/github.py
@@ -152,7 +152,32 @@
         except (self.py3.RequestException):
             return
         if info.status_code == 200:
-            return len(info.json())
+            links = info._response.headers.get('Link', '').split(', ')
+            if not links:
+                return len(info.json())
+
+            last_page = 1
+            for link in links:
+                if 'rel="last"' in link:
+                    import sys
+                    if sys.version_info[0] == 2:
+                        import urlparse
+                    else:
+                        import urllib.parse as urlparse
+                    last_url = link[link.find('<') + 1:link.find('>')]
+                    parsed = urlparse.urlparse(last_url)
+                    last_page = int(urlparse.parse_qs(parsed.query)['page'][0])
+
+            if last_page == 1:
+                return len(info.json())
+            try:
+                last_page_info = self.py3.request(last_url, timeout=10,
+                                                  auth=(self.username, self.auth_token))
+            except self.py3.RequestException:
+                return
+
+            return len(info.json()) * (last_page - 1) + len(last_page_info.json())
+
         if info.status_code == 404:
             if not self.repo_warning:
                 self.py3.notify_user('Github repo cannot be found.')

{"golden_diff": "diff --git a/py3status/modules/github.py b/py3status/modules/github.py\n--- a/py3status/modules/github.py\n+++ b/py3status/modules/github.py\n@@ -152,7 +152,32 @@\n         except (self.py3.RequestException):\n             return\n         if info.status_code == 200:\n-            return len(info.json())\n+            links = info._response.headers.get('Link', '').split(', ')\n+            if not links:\n+                return len(info.json())\n+\n+            last_page = 1\n+            for link in links:\n+                if 'rel=\"last\"' in link:\n+                    import sys\n+                    if sys.version_info[0] == 2:\n+                        import urlparse\n+                    else:\n+                        import urllib.parse as urlparse\n+                    last_url = link[link.find('<') + 1:link.find('>')]\n+                    parsed = urlparse.urlparse(last_url)\n+                    last_page = int(urlparse.parse_qs(parsed.query)['page'][0])\n+\n+            if last_page == 1:\n+                return len(info.json())\n+            try:\n+                last_page_info = self.py3.request(last_url, timeout=10,\n+                                                  auth=(self.username, self.auth_token))\n+            except self.py3.RequestException:\n+                return\n+\n+            return len(info.json()) * (last_page - 1) + len(last_page_info.json())\n+\n         if info.status_code == 404:\n             if not self.repo_warning:\n                 self.py3.notify_user('Github repo cannot be found.')\n", "issue": "GitHub: Show correct count of unread notifications\nIf you have more than 50 unread notifications in total, and you want to see that total notification count, the GitHub module still only shows 50 due to pagination:\r\n\r\nhttps://github.com/ultrabug/py3status/blob/master/py3status/modules/github.py#L155\n", "before_files": [{"content": "# -*- coding: utf-8 -*-\n\"\"\"\nDisplay Github notifications and issue/pull requests for a repo.\n\nTo check notifications a Github `username` and `personal access token` are\nrequired.  You can create a personal access token at\nhttps://github.com/settings/tokens The only `scope` needed is `notifications`,\nwhich provides readonly access to notifications.\n\nThe Github API is rate limited so setting `cache_timeout` too small may cause\nissues see https://developer.github.com/v3/#rate-limiting for details\n\nConfiguration parameters:\n    auth_token: Github personal access token, needed to check notifications\n        see above.\n        (default None)\n    button_action: Button that when clicked opens the Github notification page\n        if notifications, else the project page for the repository if there is\n        one (otherwise the github home page). Setting to `None` disables.\n        (default 3)\n    button_refresh: Button that when clicked refreshes module.\n        Setting to `None` disables.\n        (default 2)\n    cache_timeout: How often we refresh this module in seconds\n        (default 60)\n    format: Format of output\n        *(default '{repo} {issues}/{pull_requests}{notifications}'\n        if username and auth_token provided else\n        '{repo} {issues}/{pull_requests}')*\n    format_notifications: Format of `{notification}` status placeholder.\n        (default ' N{notifications_count}')\n    notifications: Type of notifications can be `all` for all notifications or\n        `repo` to only get notifications for the repo specified.  If repo is\n        not provided then all notifications will be checked.\n        (default 'all')\n    repo: Github repo to check\n        (default 'ultrabug/py3status')\n    username: Github username, needed to check notifications.\n        (default None)\n\nFormat placeholders:\n    {issues} Number of open issues.\n    {notifications} Notifications.  If no notifications this will be empty.\n    {notifications_count} Number of notifications.  This is also the __Only__\n        placeholder available to `format_notifications`.\n    {pull_requests} Number of open pull requests\n    {repo} short name of the repository being checked. eg py3status\n    {repo_full} full name of the repository being checked. eg ultrabug/py3status\n\nExamples:\n```\n# set github access credentials\ngithub {\n    auth_token = '40_char_hex_access_token'\n    username = 'my_username'\n}\n\n# just check for any notifications\ngithub {\n    auth_token = '40_char_hex_access_token'\n    username = 'my_username'\n    format = 'Github {notifications_count}'\n}\n```\n\n@author tobes\n\nSAMPLE OUTPUT\n{'full_text': 'py3status 34/24'}\n\nnotification\n{'full_text': 'py3status 34/24 N3', 'urgent': True}\n\"\"\"\n\nGITHUB_API_URL = 'https://api.github.com'\nGITHUB_URL = 'https://github.com/'\n\n\nclass Py3status:\n    auth_token = None\n    button_action = 3\n    button_refresh = 2\n    cache_timeout = 60\n    format = None\n    format_notifications = ' N{notifications_count}'\n    notifications = 'all'\n    repo = 'ultrabug/py3status'\n    username = None\n\n    def post_config_hook(self):\n        self.first = True\n        self.notification_warning = False\n        self.repo_warning = False\n        self._issues = '?'\n        self._pulls = '?'\n        self._notify = '?'\n\n    def _init(self):\n        # Set format if user has not configured it.\n        if not self.format:\n            if self.username and self.auth_token:\n                # include notifications\n                self.format = '{repo} {issues}/{pull_requests}{notifications}'\n            else:\n                self.format = '{repo} {issues}/{pull_requests}'\n\n    def _github_count(self, url):\n        \"\"\"\n        Get counts for requests that return 'total_count' in the json response.\n        \"\"\"\n        if self.first:\n            return '?'\n        url = GITHUB_API_URL + url + '&per_page=1'\n        # if we have authentication details use them as we get better\n        # rate-limiting.\n        if self.username and self.auth_token:\n            auth = (self.username, self.auth_token)\n        else:\n            auth = None\n        try:\n            info = self.py3.request(url, timeout=10, auth=auth)\n        except (self.py3.RequestException):\n            return\n        if info and info.status_code == 200:\n            return(int(info.json()['total_count']))\n        if info.status_code == 422:\n            if not self.repo_warning:\n                self.py3.notify_user('Github repo cannot be found.')\n                self.repo_warning = True\n        return '?'\n\n    def _notifications(self):\n        \"\"\"\n        Get the number of unread notifications.\n        \"\"\"\n        if not self.username or not self.auth_token:\n            if not self.notification_warning:\n                self.py3.notify_user('Github module needs username and '\n                                     'auth_token to check notifications.')\n                self.notification_warning = True\n            return '?'\n        if self.first:\n            return '?'\n        if self.notifications == 'all' or not self.repo:\n            url = GITHUB_API_URL + '/notifications'\n        else:\n            url = GITHUB_API_URL + '/repos/' + self.repo + '/notifications'\n        url += '?per_page=100'\n        try:\n            info = self.py3.request(url, timeout=10,\n                                    auth=(self.username, self.auth_token))\n        except (self.py3.RequestException):\n            return\n        if info.status_code == 200:\n            return len(info.json())\n        if info.status_code == 404:\n            if not self.repo_warning:\n                self.py3.notify_user('Github repo cannot be found.')\n                self.repo_warning = True\n\n    def github(self):\n        if self.first:\n            self._init()\n        status = {}\n        urgent = False\n        # issues\n        if self.repo and self.py3.format_contains(self.format, 'issues'):\n            url = '/search/issues?q=state:open+type:issue+repo:' + self.repo\n            self._issues = self._github_count(url) or self._issues\n        status['issues'] = self._issues\n        # pull requests\n        if self.repo and self.py3.format_contains(self.format, 'pull_requests'):\n            url = '/search/issues?q=state:open+type:pr+repo:' + self.repo\n            self._pulls = self._github_count(url) or self._pulls\n        status['pull_requests'] = self._pulls\n        # notifications\n        if (self.py3.format_contains(self.format, 'notifications') or\n                self.py3.format_contains(self.format, 'notifications_count')):\n            count = self._notifications()\n            # if we don't have a notification count, then use the last value\n            # that we did have.\n            if count is None:\n                count = self._notify\n            self._notify = count\n            if count and count != '?':\n                notify = self.py3.safe_format(\n                    self.format_notifications,\n                    {'notifications_count': count})\n                urgent = True\n            else:\n                notify = ''\n            status['notifications'] = notify\n            status['notifications_count'] = count\n        # repo\n        try:\n            status['repo'] = self.repo.split('/')[1]\n        except IndexError:\n            status['repo'] = 'Error'\n        status['repo_full'] = self.repo\n\n        if self.first:\n            cached_until = 0\n            self.first = False\n        else:\n            cached_until = self.py3.time_in(self.cache_timeout)\n\n        return {\n            'full_text': self.py3.safe_format(self.format, status),\n            'cached_until': cached_until,\n            'urgent': urgent\n        }\n\n    def on_click(self, event):\n        button = event['button']\n        if button == self.button_action:\n            # open github in browser\n            if self._notify and self._notify != '?':\n                # open github notifications page\n                url = GITHUB_URL + 'notifications'\n            else:\n                if self.notifications == 'all' and not self.repo:\n                    # open github.com if there are no unread notifications and no repo\n                    url = GITHUB_URL\n                else:\n                    # open repo page if there are no unread notifications\n                    url = GITHUB_URL + self.repo\n            # open url in default browser\n            self.py3.command_run('xdg-open {}'.format(url))\n            self.py3.prevent_refresh()\n        elif button != self.button_refresh:\n            # only refresh the module if needed\n            self.py3.prevent_refresh()\n\n\nif __name__ == \"__main__\":\n    \"\"\"\n    Run module in test mode.\n    \"\"\"\n    from py3status.module_test import module_test\n    module_test(Py3status)\n", "path": "py3status/modules/github.py"}], "after_files": [{"content": "# -*- coding: utf-8 -*-\n\"\"\"\nDisplay Github notifications and issue/pull requests for a repo.\n\nTo check notifications a Github `username` and `personal access token` are\nrequired.  You can create a personal access token at\nhttps://github.com/settings/tokens The only `scope` needed is `notifications`,\nwhich provides readonly access to notifications.\n\nThe Github API is rate limited so setting `cache_timeout` too small may cause\nissues see https://developer.github.com/v3/#rate-limiting for details\n\nConfiguration parameters:\n    auth_token: Github personal access token, needed to check notifications\n        see above.\n        (default None)\n    button_action: Button that when clicked opens the Github notification page\n        if notifications, else the project page for the repository if there is\n        one (otherwise the github home page). Setting to `None` disables.\n        (default 3)\n    button_refresh: Button that when clicked refreshes module.\n        Setting to `None` disables.\n        (default 2)\n    cache_timeout: How often we refresh this module in seconds\n        (default 60)\n    format: Format of output\n        *(default '{repo} {issues}/{pull_requests}{notifications}'\n        if username and auth_token provided else\n        '{repo} {issues}/{pull_requests}')*\n    format_notifications: Format of `{notification}` status placeholder.\n        (default ' N{notifications_count}')\n    notifications: Type of notifications can be `all` for all notifications or\n        `repo` to only get notifications for the repo specified.  If repo is\n        not provided then all notifications will be checked.\n        (default 'all')\n    repo: Github repo to check\n        (default 'ultrabug/py3status')\n    username: Github username, needed to check notifications.\n        (default None)\n\nFormat placeholders:\n    {issues} Number of open issues.\n    {notifications} Notifications.  If no notifications this will be empty.\n    {notifications_count} Number of notifications.  This is also the __Only__\n        placeholder available to `format_notifications`.\n    {pull_requests} Number of open pull requests\n    {repo} short name of the repository being checked. eg py3status\n    {repo_full} full name of the repository being checked. eg ultrabug/py3status\n\nExamples:\n```\n# set github access credentials\ngithub {\n    auth_token = '40_char_hex_access_token'\n    username = 'my_username'\n}\n\n# just check for any notifications\ngithub {\n    auth_token = '40_char_hex_access_token'\n    username = 'my_username'\n    format = 'Github {notifications_count}'\n}\n```\n\n@author tobes\n\nSAMPLE OUTPUT\n{'full_text': 'py3status 34/24'}\n\nnotification\n{'full_text': 'py3status 34/24 N3', 'urgent': True}\n\"\"\"\n\nGITHUB_API_URL = 'https://api.github.com'\nGITHUB_URL = 'https://github.com/'\n\n\nclass Py3status:\n    auth_token = None\n    button_action = 3\n    button_refresh = 2\n    cache_timeout = 60\n    format = None\n    format_notifications = ' N{notifications_count}'\n    notifications = 'all'\n    repo = 'ultrabug/py3status'\n    username = None\n\n    def post_config_hook(self):\n        self.first = True\n        self.notification_warning = False\n        self.repo_warning = False\n        self._issues = '?'\n        self._pulls = '?'\n        self._notify = '?'\n\n    def _init(self):\n        # Set format if user has not configured it.\n        if not self.format:\n            if self.username and self.auth_token:\n                # include notifications\n                self.format = '{repo} {issues}/{pull_requests}{notifications}'\n            else:\n                self.format = '{repo} {issues}/{pull_requests}'\n\n    def _github_count(self, url):\n        \"\"\"\n        Get counts for requests that return 'total_count' in the json response.\n        \"\"\"\n        if self.first:\n            return '?'\n        url = GITHUB_API_URL + url + '&per_page=1'\n        # if we have authentication details use them as we get better\n        # rate-limiting.\n        if self.username and self.auth_token:\n            auth = (self.username, self.auth_token)\n        else:\n            auth = None\n        try:\n            info = self.py3.request(url, timeout=10, auth=auth)\n        except (self.py3.RequestException):\n            return\n        if info and info.status_code == 200:\n            return(int(info.json()['total_count']))\n        if info.status_code == 422:\n            if not self.repo_warning:\n                self.py3.notify_user('Github repo cannot be found.')\n                self.repo_warning = True\n        return '?'\n\n    def _notifications(self):\n        \"\"\"\n        Get the number of unread notifications.\n        \"\"\"\n        if not self.username or not self.auth_token:\n            if not self.notification_warning:\n                self.py3.notify_user('Github module needs username and '\n                                     'auth_token to check notifications.')\n                self.notification_warning = True\n            return '?'\n        if self.first:\n            return '?'\n        if self.notifications == 'all' or not self.repo:\n            url = GITHUB_API_URL + '/notifications'\n        else:\n            url = GITHUB_API_URL + '/repos/' + self.repo + '/notifications'\n        url += '?per_page=100'\n        try:\n            info = self.py3.request(url, timeout=10,\n                                    auth=(self.username, self.auth_token))\n        except (self.py3.RequestException):\n            return\n        if info.status_code == 200:\n            links = info._response.headers.get('Link', '').split(', ')\n            if not links:\n                return len(info.json())\n\n            last_page = 1\n            for link in links:\n                if 'rel=\"last\"' in link:\n                    import sys\n                    if sys.version_info[0] == 2:\n                        import urlparse\n                    else:\n                        import urllib.parse as urlparse\n                    last_url = link[link.find('<') + 1:link.find('>')]\n                    parsed = urlparse.urlparse(last_url)\n                    last_page = int(urlparse.parse_qs(parsed.query)['page'][0])\n\n            if last_page == 1:\n                return len(info.json())\n            try:\n                last_page_info = self.py3.request(last_url, timeout=10,\n                                                  auth=(self.username, self.auth_token))\n            except self.py3.RequestException:\n                return\n\n            return len(info.json()) * (last_page - 1) + len(last_page_info.json())\n\n        if info.status_code == 404:\n            if not self.repo_warning:\n                self.py3.notify_user('Github repo cannot be found.')\n                self.repo_warning = True\n\n    def github(self):\n        if self.first:\n            self._init()\n        status = {}\n        urgent = False\n        # issues\n        if self.repo and self.py3.format_contains(self.format, 'issues'):\n            url = '/search/issues?q=state:open+type:issue+repo:' + self.repo\n            self._issues = self._github_count(url) or self._issues\n        status['issues'] = self._issues\n        # pull requests\n        if self.repo and self.py3.format_contains(self.format, 'pull_requests'):\n            url = '/search/issues?q=state:open+type:pr+repo:' + self.repo\n            self._pulls = self._github_count(url) or self._pulls\n        status['pull_requests'] = self._pulls\n        # notifications\n        if (self.py3.format_contains(self.format, 'notifications') or\n                self.py3.format_contains(self.format, 'notifications_count')):\n            count = self._notifications()\n            # if we don't have a notification count, then use the last value\n            # that we did have.\n            if count is None:\n                count = self._notify\n            self._notify = count\n            if count and count != '?':\n                notify = self.py3.safe_format(\n                    self.format_notifications,\n                    {'notifications_count': count})\n                urgent = True\n            else:\n                notify = ''\n            status['notifications'] = notify\n            status['notifications_count'] = count\n        # repo\n        try:\n            status['repo'] = self.repo.split('/')[1]\n        except IndexError:\n            status['repo'] = 'Error'\n        status['repo_full'] = self.repo\n\n        if self.first:\n            cached_until = 0\n            self.first = False\n        else:\n            cached_until = self.py3.time_in(self.cache_timeout)\n\n        return {\n            'full_text': self.py3.safe_format(self.format, status),\n            'cached_until': cached_until,\n            'urgent': urgent\n        }\n\n    def on_click(self, event):\n        button = event['button']\n        if button == self.button_action:\n            # open github in browser\n            if self._notify and self._notify != '?':\n                # open github notifications page\n                url = GITHUB_URL + 'notifications'\n            else:\n                if self.notifications == 'all' and not self.repo:\n                    # open github.com if there are no unread notifications and no repo\n                    url = GITHUB_URL\n                else:\n                    # open repo page if there are no unread notifications\n                    url = GITHUB_URL + self.repo\n            # open url in default browser\n            self.py3.command_run('xdg-open {}'.format(url))\n            self.py3.prevent_refresh()\n        elif button != self.button_refresh:\n            # only refresh the module if needed\n            self.py3.prevent_refresh()\n\n\nif __name__ == \"__main__\":\n    \"\"\"\n    Run module in test mode.\n    \"\"\"\n    from py3status.module_test import module_test\n    module_test(Py3status)\n", "path": "py3status/modules/github.py"}]}