Skip to content
This repository has been archived by the owner on Oct 15, 2022. It is now read-only.

Commit

Permalink
Refactoring code cleaner
Browse files Browse the repository at this point in the history
  • Loading branch information
Jussi Räsänen committed Jul 18, 2016
1 parent fcbe28c commit 75ccb44
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions lib/fathead/diveintopython/parse.py
Expand Up @@ -125,12 +125,15 @@ def parse_section(self, soup):
Section data, containing title, first paragraph and url to content.
"""
first_paragraph = self.clean_formatting(soup.findNext('p').get_text())
title = self.clean_formatting(soup.get_text())
anchor = self.get_url(soup)
url = os.path.join(URL_ROOT, self.file_name)

return {
'title': self.clean_formatting(soup.get_text()),
'title': title,
'paragraph': first_paragraph,
'anchor': self.get_url(soup),
'url': os.path.join(URL_ROOT, self.file_name)
'anchor': anchor,
'url': url
}

def clean_formatting(self, text):
Expand Down Expand Up @@ -163,9 +166,7 @@ def create_file(self):
title = data_element.get('title')
abstract = data_element.get('abstract')
first_paragraph = data_element.get('first_paragraph')

if abstract is None:
abstract = first_paragraph
abstract = data_element.get('abstract') or first_paragraph

if abstract is None:
continue
Expand Down

0 comments on commit 75ccb44

Please sign in to comment.