Auto-update: Thu Aug 8 19:45:04 PDT 2024
This commit is contained in:
parent
e6d8831439
commit
59415fbf9a
1 changed files with 3 additions and 11 deletions
|
@ -160,27 +160,19 @@ class Configuration(BaseModel):
|
|||
|
||||
for match in matches:
|
||||
parts = match.split('.')
|
||||
if len(parts) == 1: # Internal reference
|
||||
replacement = getattr(self, parts[0], str(Path.home() / parts[0].lower()))
|
||||
elif len(parts) == 2 and parts[0] == 'Dir':
|
||||
replacement = getattr(self, parts[1], str(Path.home() / parts[1].lower()))
|
||||
elif len(parts) == 2 and parts[0] == 'ENV':
|
||||
replacement = os.getenv(parts[1], '')
|
||||
elif len(parts) == 2 and parts[0] == 'SECRET':
|
||||
if len(parts) == 2 and parts[0] == 'SECRET':
|
||||
replacement = getattr(self, parts[1].strip(), '')
|
||||
if not replacement:
|
||||
warn(f"Secret '{parts[1].strip()}' not found in secrets file")
|
||||
else:
|
||||
replacement = value
|
||||
replacement = getattr(self, match, value)
|
||||
|
||||
value = value.replace('{{' + match + '}}', str(replacement))
|
||||
|
||||
# Convert to Path if it looks like a file path
|
||||
if isinstance(value, str) and (value.startswith(('/', '~')) or (':' in value and value[1] == ':')):
|
||||
return Path(value).expanduser()
|
||||
return value
|
||||
|
||||
|
||||
|
||||
@classmethod
|
||||
def create_dynamic_model(cls, **data):
|
||||
for key, value in data.items():
|
||||
|
|
Loading…
Reference in a new issue