Auto-update: Thu Aug 8 19:45:04 PDT 2024

This commit is contained in:
sanj 2024-08-08 19:45:04 -07:00
parent e6d8831439
commit 59415fbf9a

View file

@ -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():