mirror of https://github.com/scrapy/scrapy.git
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
This commit is contained in:
parent
d843a0aae8
commit
268e912273
|
|
@ -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 "
|
||||
|
|
|
|||
Loading…
Reference in New Issue