Transformer.attribute_value is now public

This commit is contained in:
Sergey Lavrinenko 2015-04-26 17:03:37 +03:00
parent 4fefaf0d9f
commit d4aa07002a
1 changed files with 4 additions and 2 deletions

View File

@ -212,12 +212,14 @@ class BaseTransformer(HTMLParser):
return url
def _attribute_value(self, el):
def attribute_value(self, el):
return el is not None \
and hasattr(el, 'attrib') \
and el.attrib.get(self.html_attribute_name) \
or None
_attribute_value = attribute_value # deprecated
def _default_attachment_check(self, el, hints):
if hints['attrib'] == 'ignore':
return False
@ -235,7 +237,7 @@ class BaseTransformer(HTMLParser):
# Default callback: skip images with data-emails="ignore" attribute
callback = lambda _, hints: hints['attrib'] != 'ignore'
attribute_value = self._attribute_value(element) or ''
attribute_value = self.attribute_value(element) or ''
# If callback returns False, skip attachment loading
if not callback(element, hints={'attrib': attribute_value}):