Skip to content

Commit

Permalink
Handle empty config file (#1604)
Browse files Browse the repository at this point in the history
* Fix typo in comments.

* Parse blank config files as ini files.

* Update smells_like_ini test.

* Update whats_new.rst
  • Loading branch information
SpacemanPaul committed Jun 21, 2024
1 parent 3df96cd commit 16cc0ea
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion datacube/cfg/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def __init__(
self.allow_envvar_overrides = not text and not raw_dict

if not raw_dict and not text:
# No explict config passed in. Check for ODC_CONFIG environmnet variables
# No explict config passed in. Check for ODC_CONFIG environment variables
if os.environ.get("ODC_CONFIG"):
text = os.environ["ODC_CONFIG"]
else:
Expand Down
4 changes: 2 additions & 2 deletions datacube/cfg/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,5 @@ def smells_like_ini(cfg_text: str):
return True
else:
return False
# Doesn't smell like anything
return False
# Empty file - parse as ini so we end up with the right high level structure at least
return True
2 changes: 2 additions & 0 deletions docs/about/whats_new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ What's New
v1.9.next
=========

- Ensure config API works with a blank config/empty file. (:pull:`1604`)

v1.9.0-rc8 (18th June 2024)
===========================

Expand Down
2 changes: 1 addition & 1 deletion tests/test_cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def test_smells_like_ini():
aasdfer\\faw043[]]][""")

# Pure white space
assert not smells_like_ini(" \n \n \n \n \t \t \n \n")
assert smells_like_ini(" \n \n \n \n \t \t \n \n")


@pytest.fixture
Expand Down

0 comments on commit 16cc0ea

Please sign in to comment.