feat(shared): allow loading from ini config file
This commit is contained in:
parent
65dff91d47
commit
b1ecf25d6f
2 changed files with 29 additions and 0 deletions
|
@ -1,4 +1,5 @@
|
|||
import sys
|
||||
from configparser import ConfigParser
|
||||
from os import environ
|
||||
from pathlib import Path
|
||||
from typing import Any, Dict, Optional
|
||||
|
@ -84,6 +85,12 @@ class BaseConfig(BaseModel):
|
|||
if filepath is None:
|
||||
return {}
|
||||
|
||||
# TODO: Remove ability to load ini files once yaml if fully supported.
|
||||
if filepath.suffix == ".conf":
|
||||
config = ConfigParser()
|
||||
config.read_string(filepath.read_text(encoding="utf-8"))
|
||||
return {s: dict(config.items(s)) for s in config.sections()}
|
||||
|
||||
try:
|
||||
return safe_load(filepath.read_text(encoding="utf-8"))
|
||||
except YAMLError as error:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue