mirror of https://github.com/scrapy/scrapy.git
updated docstrings for remove_escape_chars and its adaptor factory
This commit is contained in:
parent
1b3d40e639
commit
da7b9358a4
|
|
@ -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
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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))
|
||||
|
|
|
|||
Loading…
Reference in New Issue