提交 268e9122 编写于 作者: P Paul Tremberth

Add pretty-printting of settings as dict if using IPython shell

Suggested by @digenis
see http://ipython.readthedocs.org/en/stable/api/generated/IPython.lib.pretty.html?#extending
上级 d843a0aa
......@@ -4,6 +4,7 @@ import copy
import warnings
from collections import MutableMapping
from importlib import import_module
from pprint import pformat
from scrapy.utils.deprecate import create_deprecated_class
from scrapy.exceptions import ScrapyDeprecationWarning
......@@ -388,6 +389,12 @@ class BaseSettings(MutableMapping):
settings = self.copy()
return settings._to_dict()
def _repr_pretty_(self, p, cycle):
if cycle:
p.text(repr(self))
else:
p.text(pformat(self.copy_to_dict()))
@property
def overrides(self):
warnings.warn("`Settings.overrides` attribute is deprecated and won't "
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册