Skip to content

Commit

Permalink
Better pattern matching for config names
Browse files Browse the repository at this point in the history
  • Loading branch information
4Kaylum committed Aug 23, 2023
1 parent d1cc614 commit f6986e3
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion novus/ext/client/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,17 @@ def check(name: str) -> bool:
def from_file(cls, filename: str | None) -> Self:
if filename is None:
try:
filename = glob.glob("config.*")[0]
possible_filenames: list[str] = glob.glob("config.*")
possible_filenames[0]
except IndexError:
log.warning("Missing config file from current directory")
return cls()
for end in ["yaml", "toml", "json"]:
if f"config.{end}" in possible_filenames:
filename = f"config.{end}"
break
else:
filename = possible_filenames[0]
try:
if filename.endswith(".yaml") or filename.endswith(".yml"):
return cls.from_yaml(filename)
Expand Down

0 comments on commit f6986e3

Please sign in to comment.