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"
)
| 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 |