MCPcopy
hub / github.com/scrapy/scrapy / getdict

Method getdict

scrapy/settings/__init__.py:253–274  ·  view source on GitHub ↗

Get a setting value as a dictionary. If the setting original type is a dictionary, a copy of it will be returned. If it is a string it will be evaluated as a JSON dictionary. In the case that it is a :class:`~scrapy.settings.BaseSettings` instance itself, it will be

(
        self, name: _SettingsKey, default: dict[Any, Any] | None = None
    )

Source from the content-addressed store, hash-verified

251 return list(value)
252
253 def getdict(
254 self, name: _SettingsKey, default: dict[Any, Any] | None = None
255 ) -> dict[Any, Any]:
256 """
257 Get a setting value as a dictionary. If the setting original type is a
258 dictionary, a copy of it will be returned. If it is a string it will be
259 evaluated as a JSON dictionary. In the case that it is a
260 :class:`~scrapy.settings.BaseSettings` instance itself, it will be
261 converted to a dictionary, containing all its current settings values
262 as they would be returned by :meth:`~scrapy.settings.BaseSettings.get`,
263 and losing all information about priority and mutability.
264
265 :param name: the setting name
266 :type name: str
267
268 :param default: the value to return if no setting is found
269 :type default: object
270 """
271 value = self.get(name, default or {})
272 if isinstance(value, str):
273 value = json.loads(value)
274 return dict(value)
275
276 def getdictorlist(
277 self,

Callers 12

__init__Method · 0.80
from_crawlerMethod · 0.80
__init__Method · 0.80
__init__Method · 0.80
__init__Method · 0.80
test_getMethod · 0.80

Calls 1

getMethod · 0.95

Tested by 4

__init__Method · 0.64
test_getMethod · 0.64