MCPcopy
hub / github.com/scrapy/scrapy / get_project_settings

Function get_project_settings

scrapy/utils/project.py:66–91  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

64
65
66def get_project_settings() -> Settings:
67 if ENVVAR not in os.environ:
68 project = os.environ.get("SCRAPY_PROJECT", "default")
69 init_env(project)
70
71 settings = Settings()
72 settings_module_path = os.environ.get(ENVVAR)
73 if settings_module_path:
74 settings.setmodule(settings_module_path, priority="project")
75
76 valid_envvars = {
77 "CHECK",
78 "PROJECT",
79 "PYTHON_SHELL",
80 "SETTINGS_MODULE",
81 }
82
83 scrapy_envvars = {
84 k[7:]: v
85 for k, v in os.environ.items()
86 if k.startswith("SCRAPY_") and k.replace("SCRAPY_", "") in valid_envvars
87 }
88
89 settings.setdict(scrapy_envvars, priority="project")
90
91 return settings

Callers 4

executeFunction · 0.90
test_valid_envvarMethod · 0.90
test_invalid_envvarMethod · 0.90

Calls 7

init_envFunction · 0.90
SettingsClass · 0.90
setmoduleMethod · 0.80
itemsMethod · 0.80
setdictMethod · 0.80
getMethod · 0.45
replaceMethod · 0.45

Tested by 3

test_valid_envvarMethod · 0.72
test_invalid_envvarMethod · 0.72