Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix API date format #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions pytrend_cli/pytrend.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,20 +60,20 @@ def get_programming_language(repo_info):
return


def stars_and_pull_requests(repo_info):
"""Return total stars and pull requests"""
def stars_and_forks(repo_info):
"""Return total stars and forks"""
try:
data = repo_info.select('a.muted-link')
# Handle no stars/pull requests data on repo
# Handle no stars/forks data on repo
try:
stars = data[0].text.strip()
except IndexError:
stars = None
try:
pull_requests = data[1].text.strip()
forks = data[1].text.strip()
except IndexError:
pull_requests = None
return stars, pull_requests
forks = None
return stars, forks
except AttributeError:
return

Expand All @@ -96,15 +96,15 @@ def parse_repositories_info(tag):
repositories = content.find_all('li')
for index, list_item in enumerate(repositories, start=1):
username, repo_name = username_and_reponame(list_item)
stars, pull_requests = stars_and_pull_requests(list_item)
stars, forks = stars_and_forks(list_item)
trending[index] = {
'User': username,
'Repository': repo_name,
'URL': BASE_URL + '/'.join((username, repo_name)),
'Description': get_description(list_item),
'Programming Language': get_programming_language(list_item),
'Total stars': stars,
'Pull requests': pull_requests,
'Forks': forks,
'Stars trending': get_stars_trending(list_item)
}
return trending
Expand Down