Skip to content

Scrapy, a fast high-level web crawling & scraping framework for Python.

updated docstrings for remove_escape_chars and its adaptor factory

Ismael Carnalesda7b9358a497
diff --git a/scrapy/contrib_exp/adaptors/markup.py b/scrapy/contrib_exp/adaptors/markup.py
index b8f29d3ed..13a6f16de 100644
--- a/scrapy/contrib_exp/adaptors/markup.py
+++ b/scrapy/contrib_exp/adaptors/markup.py
@@ -31,20 +31,20 @@ def remove_root(value):
return str_to_unicode(value)
-def remove_escape(which_ones=('\n','\t','\r'), replace_str=u''):
+def remove_escape(which_ones=('\n','\t','\r'), replace_by=u''):
"""
Factory that returns an adaptor for removing/replacing each escape
character in the `wich_ones` parameter found in the given value.
- If `replace_str` is given, escape characters are replaced by that
- string, else they're removed.
+ If `replace_by` is given, escape characters are replaced by that
+ text, else they're removed.
Input: string/unicode
Output: unicode
"""
def _remove_escape(value):
- return remove_escape_chars(value, which_ones, replace_str)
+ return remove_escape_chars(value, which_ones, replace_by)
return _remove_escape
diff --git a/scrapy/utils/markup.py b/scrapy/utils/markup.py
index 9a9786072..fd6e1dc25 100644
--- a/scrapy/utils/markup.py
+++ b/scrapy/utils/markup.py
@@ -110,6 +110,9 @@ def remove_escape_chars(text, which_ones=('\n','\t','\r'), replace_by=u''):
which_ones -- is a tuple of which escape chars we want to remove.
By default removes \n, \t, \r.
+
+ replace_by -- text to replace the escape chars for.
+ It defaults to '', so the escape chars are removed.
"""
for ec in which_ones:
text = text.replace(ec, str_to_unicode(replace_by))