Return the current project data dir, creating it if it doesn't exist
(project: str = "default")
| 29 | |
| 30 | |
| 31 | def 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 | |
| 50 | def data_path(path: str | os.PathLike[str], createdir: bool = False) -> str: |
no test coverage detected