Remove replaced_by_env_path decorator

This commit is contained in:
kramo
2023-06-10 20:54:49 +02:00
parent de3ef53148
commit d340e007e3
7 changed files with 12 additions and 41 deletions

View File

@@ -22,24 +22,6 @@ def replaced_by_path(override: PathLike): # Decorator builder
return decorator
def replaced_by_env_path(env_var_name: str, suffix: PathLike | None = None):
"""Replace the method's returned path with a path whose root is the env variable"""
def decorator(original_function): # Built decorator (closure)
@wraps(original_function)
def wrapper(*args, **kwargs): # func's override
try:
env_var = environ[env_var_name]
except KeyError:
return original_function(*args, **kwargs)
override = Path(env_var) / suffix
return replaced_by_path(override)(original_function)(*args, **kwargs)
return wrapper
return decorator
def replaced_by_schema_key(original_method): # Built decorator (closure)
"""
Replace the original method's value by the path pointed at in the schema