From 009a87184a53f12439a812c6f8e5ee1362fedd45 Mon Sep 17 00:00:00 2001 From: Birger Schacht Date: Tue, 18 Jun 2024 14:50:07 +0200 Subject: [PATCH] refactor(utils): drop unused method --- apis_core/utils/helpers.py | 38 -------------------------------------- 1 file changed, 38 deletions(-) diff --git a/apis_core/utils/helpers.py b/apis_core/utils/helpers.py index 9b16b585a..efb45b11c 100644 --- a/apis_core/utils/helpers.py +++ b/apis_core/utils/helpers.py @@ -1,8 +1,5 @@ import difflib -import importlib -import inspect import itertools -import logging from apis_core.apis_relations.models import Property, TempTriple @@ -47,41 +44,6 @@ def get_content_types_with_allowed_relation_from( return set(itertools.chain(*content_type_querysets)) -def get_member_for_entity( - model: object, suffix: str = None, path: str = None -) -> object: - """ - Look for a module memeber whose name and location are derived from a Django model, - a suffix and optinally a path. The name is derived from the modelname and the suffix. - The location is derived from the models app_name and the path. If no path is - given, a default path is generated by using the suffix + "s". - So for example with a model `apis_ontology.Person` and suffix `Table` it returns - `apis_ontology.tables.PersonTable` if it exists. If it does not find a matching member, it - returns None. If we add the path "mytables" it looks for the member - `apis_ontology.mytables.PersonTable`. - """ - ct = ContentType.objects.get_for_model(model) - module = ct.app_label - model = ct.model.capitalize() - if suffix: - model += suffix - if path: - module += f".{path}" - else: - if suffix: - module += f".{suffix.lower()}s" - logging.debug("Checking if %s.%s exists", module, model) - try: - members = inspect.getmembers(importlib.import_module(module)) - members = list(filter(lambda c: c[0] == model, members)) - except ModuleNotFoundError: - members = [] - if members: - logging.debug("Found %s.%s", module, model) - return members[0][1] - return None - - def datadump_get_objects(models: list = [], *args, **kwargs): for model in models: if not model._meta.proxy and router.allow_migrate_model(