Skip to content

Commit

Permalink
Fix trending command to handle empty summaries (donnemartin#129)
Browse files Browse the repository at this point in the history
  • Loading branch information
emres authored and donnemartin committed Sep 3, 2017
1 parent 92b69ca commit 7359a0c
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions gitsome/formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -587,10 +587,16 @@ def format_trending_entry(self, view_entry):
item_parts = trending_entry.title.split(' ')
title = item_parts[0]
item = self.format_index_title(view_entry.index, title)
summary_parts = trending_entry.summary.split('\n')
summary = summary_parts[0] if len(summary_parts) > 1 else ''
summary = self.strip_line_breaks(summary)
language = summary_parts[-1]

try:
summary_parts = trending_entry.summary.split('\n')
summary = summary_parts[0] if len(summary_parts) > 1 else ''
summary = self.strip_line_breaks(summary)
language = summary_parts[-1]
except AttributeError:
summary = ''
language = ''

if language == '()':
language = '(Unknown)'
language = re.sub(r'(\()', r'', language)
Expand Down

0 comments on commit 7359a0c

Please sign in to comment.