mirror of https://github.com/scrapy/scrapy.git
minor changes
This commit is contained in:
parent
fa25549f3f
commit
97862e765e
|
|
@ -7,7 +7,12 @@ from pathlib import Path
|
|||
|
||||
from scrapy.exceptions import NotConfigured
|
||||
from scrapy.settings import Settings
|
||||
from scrapy.utils.conf import closest_scrapy_cfg, get_config, init_env
|
||||
from scrapy.utils.conf import (
|
||||
closest_pyproject_toml,
|
||||
closest_scrapy_cfg,
|
||||
get_config,
|
||||
init_env,
|
||||
)
|
||||
|
||||
ENVVAR = "SCRAPY_SETTINGS_MODULE"
|
||||
DATADIR_CFG_SECTION = "datadir"
|
||||
|
|
@ -24,7 +29,7 @@ def inside_project() -> bool:
|
|||
)
|
||||
else:
|
||||
return True
|
||||
return bool(closest_scrapy_cfg())
|
||||
return bool(closest_scrapy_cfg() or closest_pyproject_toml())
|
||||
|
||||
|
||||
def project_data_dir(project: str = "default") -> str:
|
||||
|
|
@ -35,10 +40,10 @@ def project_data_dir(project: str = "default") -> str:
|
|||
if cfg.has_option(DATADIR_CFG_SECTION, project):
|
||||
d = Path(cfg.get(DATADIR_CFG_SECTION, project))
|
||||
else:
|
||||
scrapy_cfg = closest_scrapy_cfg()
|
||||
scrapy_cfg = closest_scrapy_cfg() or closest_pyproject_toml()
|
||||
if not scrapy_cfg:
|
||||
raise NotConfigured(
|
||||
"Unable to find scrapy.cfg file to infer project data dir"
|
||||
"Unable to find scrapy.cfg or pyproject.toml to infer project data dir"
|
||||
)
|
||||
d = (Path(scrapy_cfg).parent / ".scrapy").resolve()
|
||||
if not d.exists():
|
||||
|
|
|
|||
Loading…
Reference in New Issue