Skip to content

Commit

Permalink
Merge pull request #137 from jtpio/config-files-check
Browse files Browse the repository at this point in the history
Fix handling of releaser config in multiple files
  • Loading branch information
Steven Silvester authored Sep 7, 2021
2 parents 506beb6 + 0ca001f commit a5be6ea
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions jupyter_releaser/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,21 +271,26 @@ def retry(cmd, **kwargs):

def read_config():
"""Read the jupyter-releaser config data"""
config = {}
config = None

if JUPYTER_RELEASER_CONFIG.exists():
config = toml.loads(JUPYTER_RELEASER_CONFIG.read_text(encoding="utf-8"))

elif PYPROJECT.exists():
if not config and PYPROJECT.exists():
data = toml.loads(PYPROJECT.read_text(encoding="utf-8"))
config = data.get("tool", {}).get("jupyter-releaser") or {}
pyproject_config = data.get("tool", {}).get("jupyter-releaser")
if pyproject_config:
config = pyproject_config

elif PACKAGE_JSON.exists():
if not config and PACKAGE_JSON.exists():
data = json.loads(PACKAGE_JSON.read_text(encoding="utf-8"))
if "jupyter-releaser" in data:
config = data["jupyter-releaser"]

with open(osp.join(HERE, "schema.json")) as fid:
schema = json.load(fid)

config = config or {}
validator = Validator(schema)
validator.validate(config)
return config

0 comments on commit a5be6ea

Please sign in to comment.