|
18 | 18 | from subprocess import PIPE
|
19 | 19 |
|
20 | 20 | import toml
|
| 21 | +from jsonschema import Draft4Validator as Validator |
21 | 22 | from pkg_resources import parse_version
|
22 | 23 |
|
23 | 24 | from jupyter_releaser.tee import run as tee
|
24 | 25 |
|
| 26 | +HERE = osp.dirname(osp.abspath(__file__)) |
25 | 27 | PYPROJECT = Path("pyproject.toml")
|
26 | 28 | SETUP_PY = Path("setup.py")
|
27 | 29 | SETUP_CFG = Path("setup.cfg")
|
@@ -269,18 +271,21 @@ def retry(cmd, **kwargs):
|
269 | 271 |
|
270 | 272 | def read_config():
|
271 | 273 | """Read the jupyter-releaser config data"""
|
| 274 | + config = {} |
272 | 275 | if JUPYTER_RELEASER_CONFIG.exists():
|
273 |
| - return toml.loads(JUPYTER_RELEASER_CONFIG.read_text(encoding="utf-8")) |
| 276 | + config = toml.loads(JUPYTER_RELEASER_CONFIG.read_text(encoding="utf-8")) |
274 | 277 |
|
275 |
| - if PYPROJECT.exists(): |
| 278 | + elif PYPROJECT.exists(): |
276 | 279 | data = toml.loads(PYPROJECT.read_text(encoding="utf-8"))
|
277 |
| - config = data.get("tool", {}).get("jupyter-releaser") |
278 |
| - if config: |
279 |
| - return config |
| 280 | + config = data.get("tool", {}).get("jupyter-releaser") or {} |
280 | 281 |
|
281 |
| - if PACKAGE_JSON.exists(): |
| 282 | + elif PACKAGE_JSON.exists(): |
282 | 283 | data = json.loads(PACKAGE_JSON.read_text(encoding="utf-8"))
|
283 | 284 | if "jupyter-releaser" in data:
|
284 |
| - return data["jupyter-releaser"] |
| 285 | + config = data["jupyter-releaser"] |
285 | 286 |
|
286 |
| - return {} |
| 287 | + with open(osp.join(HERE, "schema.json")) as fid: |
| 288 | + schema = json.load(fid) |
| 289 | + validator = Validator(schema) |
| 290 | + validator.validate(config) |
| 291 | + return config |
0 commit comments