Skip to content

Commit

Permalink
fix(package/trend): when there is no star provided on the GitHub module
Browse files Browse the repository at this point in the history
  • Loading branch information
louistiti committed Apr 25, 2019
1 parent 815f8c9 commit 563fb40
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions packages/trend/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,17 @@ def github(string, entities):
author = element.img.get('alt')[1:]
else:
author = '?'
stars = element.select('span.d-inline-block.float-sm-right')[0].get_text(strip=True).split(' ')[0]
separators = [' ', ',', '.']

# Replace potential separators number
for j, separator in enumerate(separators):
stars = stars.replace(separator, '')
hasstars = element.select('span.d-inline-block.float-sm-right')
stars = 0

if hasstars:
stars = element.select('span.d-inline-block.float-sm-right')[0].get_text(strip=True).split(' ')[0]
separators = [' ', ',', '.']

# Replace potential separators number
for j, separator in enumerate(separators):
stars = stars.replace(separator, '')

result += utils.translate('list_element', {
'rank': i + 1,
Expand Down

0 comments on commit 563fb40

Please sign in to comment.