MCPcopy
hub / github.com/scrapy/scrapy / set

Method set

scrapy/settings/__init__.py:459–487  ·  view source on GitHub ↗

Store a key/value attribute with a given priority. Settings should be populated *before* configuring the Crawler object (through the :meth:`~scrapy.crawler.Crawler.configure` method), otherwise they won't have any effect. :param name: the setting name

(
        self, name: _SettingsKey, value: Any, priority: int | str = "project"
    )

Source from the content-addressed store, hash-verified

457 self.set(name, value)
458
459 def set(
460 self, name: _SettingsKey, value: Any, priority: int | str = "project"
461 ) -> None:
462 """
463 Store a key/value attribute with a given priority.
464
465 Settings should be populated *before* configuring the Crawler object
466 (through the :meth:`~scrapy.crawler.Crawler.configure` method),
467 otherwise they won't have any effect.
468
469 :param name: the setting name
470 :type name: str
471
472 :param value: the value to associate with the setting
473 :type value: object
474
475 :param priority: the priority of the setting. Should be a key of
476 :attr:`~scrapy.settings.SETTINGS_PRIORITIES` or an integer
477 :type priority: str or int
478 """
479 self._assert_mutability()
480 priority = get_settings_priority(priority)
481 if name not in self:
482 if isinstance(value, SettingsAttribute):
483 self.attributes[name] = value
484 else:
485 self.attributes[name] = SettingsAttribute(value, priority)
486 else:
487 self.attributes[name].set(value, priority)
488
489 def set_in_component_priority_dict(
490 self, name: _SettingsKey, cls: type, priority: int | None

Callers 15

_map_keysFunction · 0.95
add_to_listMethod · 0.95
remove_from_listMethod · 0.95
__setitem__Method · 0.95
setdefaultMethod · 0.95
setmoduleMethod · 0.95
updateMethod · 0.95
test_update_settingsMethod · 0.95

Calls 3

_assert_mutabilityMethod · 0.95
get_settings_priorityFunction · 0.85
SettingsAttributeClass · 0.85