mirror of
https://github.com/JimmXinu/FanFicFare.git
synced 2026-04-29 10:25:43 +02:00
Correct 'hasattr' call for bs3 back compat.
This commit is contained in:
parent
e414f522c6
commit
6aca8d2656
2 changed files with 4 additions and 4 deletions
|
|
@ -114,6 +114,7 @@ class PageElement(object):
|
|||
"""Contains the navigational information for some part of the page
|
||||
(either a tag or a piece of text)"""
|
||||
|
||||
## Added for FFDL.
|
||||
bs3=True
|
||||
|
||||
def setup(self, parent=None, previous=None):
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ def _replaceNotEntities(data):
|
|||
return p.sub(r'&\1', data)
|
||||
|
||||
def stripHTML(soup):
|
||||
if isinstance(soup,basestring) or soup.has_attr('bs3'):
|
||||
if isinstance(soup,basestring) or hasattr(soup, 'bs3'):
|
||||
return removeAllEntities(re.sub(r'<[^>]+>','',"%s" % soup)).strip()
|
||||
else:
|
||||
# bs4 already converts all the entities to UTF8 chars.
|
||||
|
|
@ -72,10 +72,9 @@ def removeAllEntities(text):
|
|||
# Remove < < and &
|
||||
return removeEntities(text).replace('<', '<').replace('>', '>').replace('&', '&')
|
||||
|
||||
def removeEntities(text):
|
||||
|
||||
def removeEntities(text):
|
||||
if text is None:
|
||||
return ""
|
||||
return u""
|
||||
|
||||
if not isinstance(text,basestring):
|
||||
return unicode(text)
|
||||
|
|
|
|||
Loading…
Reference in a new issue