diff --git a/scrapy/utils/display.py b/scrapy/utils/display.py index 3caf716b1..cb1a64f3d 100644 --- a/scrapy/utils/display.py +++ b/scrapy/utils/display.py @@ -5,7 +5,6 @@ import sys import pprint as pypprint from scrapy.item import BaseItem -from scrapy.http import Request, Response nocolour = False @@ -20,30 +19,25 @@ def colorize(text): except ImportError: return text -def pformat_dictobj(obj): +def _pformat_dictobj(obj): clsname = obj.__class__.__name__ return "%s(%s)\n" % (clsname, colorize(pypprint.pformat(obj.__dict__))) -def pprint_dictobj(obj): - print pformat_dictobj(obj) - def pformat(obj, *args, **kwargs): """ Wrapper which autodetects the object type and uses the proper formatting function """ - - if isinstance(obj, (list, tuple)): - return "".join([pformat(i, *args, **kwargs) for i in obj]) - elif isinstance(obj, (BaseItem, Request, Response)): - return pformat_dictobj(obj) + if isinstance(obj, BaseItem): + return _pformat_dictobj(obj) + elif hasattr(obj, '__iter__'): + return "".join(map(pformat, obj)) else: - return colorize(pypprint.pformat(obj)) + return colorize(pypprint.pformat(repr(obj))) def pprint(obj, *args, **kwargs): """ Wrapper which autodetects the object type and uses the proper printing function """ - print pformat(obj, *args, **kwargs)