GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — rename the document_only flag to html_partial · elcsong/python-readability@46f0302

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • readability
    • readability.py
  • tests
    • test_article_only.py
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎readability/readability.py‎

Copy file name to clipboardExpand all lines: readability/readability.py
+6-6Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,10 @@ def title(self):
123123
def short_title(self):
124124
return shorten_title(self._html(True))
125125

126-
def summary(self, document_only=False):
126+
def summary(self, html_partial=False):
127127
"""Generate the summary of the html docuemnt
128128
129-
:param document_only: return only the div of the document, don't wrap
129+
:param html_partial: return only the div of the document, don't wrap
130130
in html and body tags.
131131
132132
"""
@@ -147,7 +147,7 @@ def summary(self, document_only=False):
147147

148148
if best_candidate:
149149
article = self.get_article(candidates, best_candidate,
150-
document_only=document_only)
150+
html_partial=html_partial)
151151
else:
152152
if ruthless:
153153
log.debug("ruthless removal did not work. ")
@@ -180,15 +180,15 @@ def summary(self, document_only=False):
180180
log.exception('error getting summary: ')
181181
raise Unparseable(str(e)), None, sys.exc_info()[2]
182182

183-
def get_article(self, candidates, best_candidate, document_only=False):
183+
def get_article(self, candidates, best_candidate, html_partial=False):
184184
# Now that we have the top candidate, look through its siblings for
185185
# content that might also be related.
186186
# Things like preambles, content split by ads that we removed, etc.
187187
sibling_score_threshold = max([
188188
10,
189189
best_candidate['content_score'] * 0.2])
190190
# create a new html document with a html->body->div
191-
if document_only:
191+
if html_partial:
192192
output = fragment_fromstring('<div/>')
193193
else:
194194
output = document_fromstring('<div/>')
@@ -219,7 +219,7 @@ def get_article(self, candidates, best_candidate, document_only=False):
219219
if append:
220220
# We don't want to append directly to output, but the div
221221
# in html->body->div
222-
if document_only:
222+
if html_partial:
223223
output.append(sibling)
224224
else:
225225
output.getchildren()[0].getchildren()[0].append(sibling)
Collapse file

‎tests/test_article_only.py‎

Copy file name to clipboardExpand all lines: tests/test_article_only.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ def test_si_sample(self):
3030
res = doc.summary()
3131
self.assertEqual('<html><body><div><div class', res[0:27])
3232

33-
def test_si_sample_doc_only(self):
33+
def test_si_sample_html_partial(self):
3434
"""Using the si sample, make sure we can get the article alone."""
3535
sample = load_sample('si-game.sample.html')
3636
doc = Document(sample, url='http://sportsillustrated.cnn.com/baseball/mlb/gameflash/2012/04/16/40630_preview.html')
37-
res = doc.summary(document_only=True)
37+
res = doc.summary(html_partial=True)
3838
self.assertEqual('<div><div class="', res[0:17])
3939

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.