mirror of
https://github.com/ManiMatter/decluttarr.git
synced 2026-04-17 21:53:58 +02:00
Fixing filter of internal attributes
This commit is contained in:
@@ -17,10 +17,10 @@ def filter_internal_attributes(data, internal_attributes, hide_internal_attr):
|
||||
|
||||
def clean_dict(data, sensitive_attributes, internal_attributes, hide_internal_attr):
|
||||
"""Clean a dictionary by masking sensitive attributes and filtering internal ones."""
|
||||
cleaned = {
|
||||
masked = {
|
||||
k: mask_sensitive_value(v, k, sensitive_attributes) for k, v in data.items()
|
||||
}
|
||||
return filter_internal_attributes(cleaned, internal_attributes, hide_internal_attr)
|
||||
return filter_internal_attributes(masked, internal_attributes, hide_internal_attr)
|
||||
|
||||
|
||||
def clean_list(obj, sensitive_attributes, internal_attributes, hide_internal_attr):
|
||||
@@ -57,7 +57,8 @@ def clean_object(obj, sensitive_attributes, internal_attributes, hide_internal_a
|
||||
return clean_dict(
|
||||
vars(obj), sensitive_attributes, internal_attributes, hide_internal_attr
|
||||
)
|
||||
return mask_sensitive_value(obj, "", sensitive_attributes)
|
||||
|
||||
return obj
|
||||
|
||||
|
||||
def get_config_as_yaml(
|
||||
@@ -92,13 +93,13 @@ def get_config_as_yaml(
|
||||
|
||||
# Process dict or class-like object config
|
||||
else:
|
||||
cleaned_obj = clean_object(
|
||||
obj,
|
||||
sensitive_attributes,
|
||||
internal_attributes,
|
||||
hide_internal_attr,
|
||||
)
|
||||
if cleaned_obj:
|
||||
if not key in internal_attributes and hide_internal_attr:
|
||||
cleaned_obj = clean_object(
|
||||
obj,
|
||||
sensitive_attributes,
|
||||
internal_attributes,
|
||||
hide_internal_attr,
|
||||
)
|
||||
config_output[key] = cleaned_obj
|
||||
|
||||
return yaml.dump(
|
||||
|
||||
@@ -11,7 +11,7 @@ class Envs:
|
||||
self.use_config_yaml = False # Overwritten later if config file exists
|
||||
|
||||
def config_as_yaml(self):
|
||||
return get_config_as_yaml(self.__dict__)
|
||||
return get_config_as_yaml(vars(self), internal_attributes={"in_docker"})
|
||||
|
||||
|
||||
class Paths:
|
||||
|
||||
Reference in New Issue
Block a user