MCPcopy
hub / github.com/scrapy/scrapy / project_data_dir

Function project_data_dir

scrapy/utils/project.py:31–47  ·  view source on GitHub ↗

Return the current project data dir, creating it if it doesn't exist

(project: str = "default")

Source from the content-addressed store, hash-verified

29
30
31def project_data_dir(project: str = "default") -> str:
32 """Return the current project data dir, creating it if it doesn't exist"""
33 if not inside_project():
34 raise NotConfigured("Not inside a project")
35 cfg = get_config()
36 if cfg.has_option(DATADIR_CFG_SECTION, project):
37 d = Path(cfg.get(DATADIR_CFG_SECTION, project))
38 else:
39 scrapy_cfg = closest_scrapy_cfg()
40 if not scrapy_cfg:
41 raise NotConfigured(
42 "Unable to find scrapy.cfg file to infer project data dir"
43 )
44 d = (Path(scrapy_cfg).parent / ".scrapy").resolve()
45 if not d.exists():
46 d.mkdir(parents=True)
47 return str(d)
48
49
50def data_path(path: str | os.PathLike[str], createdir: bool = False) -> str:

Callers 1

data_pathFunction · 0.85

Calls 5

NotConfiguredClass · 0.90
get_configFunction · 0.90
closest_scrapy_cfgFunction · 0.90
inside_projectFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected