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

Don't through exception when HTML title is empty #1

Merged
merged 1 commit into from
Jan 25, 2013
Merged

Don't through exception when HTML title is empty #1

merged 1 commit into from
Jan 25, 2013

Conversation

yaph
Copy link
Contributor

@yaph yaph commented Jan 24, 2013

When extracting content from an HTML file with an empty title an exception occurs, see traceback below. To avoid this I added a call to filter to remove possible None values from data_values in the cleanup function. I also added a test.

Traceback (most recent call last):
  File "tests/tests.py", line 123, in test_empty_title
    extracted = self.extractor.extract(EMPTY_TITLE_HTML)
  File "/home/ramiro/repos/pub/bookmark-tools/local/lib/python2.7/site-packages/extraction/__init__.py", line 248, in extract
    return self.extracted_class(**self.cleanup(extracted, html, source_url=source_url))
  File "/home/ramiro/repos/pub/bookmark-tools/local/lib/python2.7/site-packages/extraction/__init__.py", line 211, in cleanup
    data_values = [self.cleanup_text(x) for x in data_values]
  File "/home/ramiro/repos/pub/bookmark-tools/local/lib/python2.7/site-packages/extraction/__init__.py", line 183, in cleanup_text
    return " ".join(value.split())
AttributeError: 'NoneType' object has no attribute 'split'

@lethain
Copy link
Owner

lethain commented Jan 25, 2013

Awesome! Much appreciated, merging it in.

lethain added a commit that referenced this pull request Jan 25, 2013
Don't through exception when HTML title is empty
@lethain lethain merged commit 6bdedc0 into lethain:master Jan 25, 2013
lethain pushed a commit that referenced this pull request Jun 6, 2014
Merge pull request #1 from lethain/svven
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants