diff --git a/anonymiser/registry.py b/anonymiser/registry.py index 21e67a7..7383eb7 100644 --- a/anonymiser/registry.py +++ b/anonymiser/registry.py @@ -18,12 +18,9 @@ def sort_by_name(models: list[type[models.Model]]) -> list[type[models.Model]]: class Registry(dict): - def anonymisable_models(self) -> list[type[models.Model]]: + def get_anonymisable_models(self) -> list[type[models.Model]]: return sort_by_name([m for m in self.keys() if self[m]]) - def non_anonymisable_models(self) -> list[type[models.Model]]: - return sort_by_name([m for m in self.keys() if self[m] is None]) - def is_model_anonymisable(self, model: type[models.Model]) -> bool: return bool(self[model]) @@ -48,6 +45,11 @@ def get_model_anonymiser(model: type[models.Model]) -> ModelAnonymiser | None: return None +def get_anonymisable_models() -> list[type[models.Model]]: + """Return all models that have an anonymiser.""" + return _registry.get_anonymisable_models() + + def get_all_model_fields( anonymised_only: bool = False, ) -> dict[str, list[ModelFieldSummary]]: @@ -73,5 +75,5 @@ def get_all_model_fields( return dict(output) -# Registry object - initialised in init_registry() -_registry: Registry = Registry() +# principle access point for the registry +_registry = Registry()