Skip to content

Commit

Permalink
fix github get repos
Browse files Browse the repository at this point in the history
  • Loading branch information
sirfoga committed Jul 25, 2018
1 parent 6292edf commit 6e5102a
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions hal/internet/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

from bs4 import BeautifulSoup

from internet.utils import add_params_to_url
from .utils import add_params_to_url

GITHUB_URL = "https://github.com"
API_URL = "https://api.github.com/" # Github api url
Expand Down Expand Up @@ -95,7 +95,6 @@ def _get_api_content(self):
)

api_content_response = urllib.request.urlopen(api_content_request)
print(api_content_response)
self.api_content = json.loads(
api_content_response.read().decode("utf-8")) # parse response

Expand Down Expand Up @@ -192,13 +191,25 @@ def get_repos(self):
"""

user_repos_url = self["repos_url"]
api_driver = GithubRawApi(
user_repos_url, True
) # driver to parse API content
current_page = 1
there_is_something_left = True
repos_list = []
for repo in api_driver.api_content: # list of raw repository
repo_name = repo["name"]
repos_list.append(GithubUserRepository(self.username, repo_name))

while there_is_something_left:
api_driver = GithubRawApi(
user_repos_url,
url_params={"page": current_page},
get_api_content_now=True
) # driver to parse API content

for repo in api_driver.api_content: # list of raw repository
repo_name = repo["name"]
repos_list.append(
GithubUserRepository(self.username, repo_name))

there_is_something_left = len(api_driver.api_content) > 0
current_page += 1

return repos_list

def get_starred_repos(self):
Expand Down

0 comments on commit 6e5102a

Please sign in to comment.