Skip to content

Commit

Permalink
refactor(utils): drop unused method
Browse files Browse the repository at this point in the history
  • Loading branch information
b1rger committed Jun 19, 2024
1 parent 5c40bc0 commit 009a871
Showing 1 changed file with 0 additions and 38 deletions.
38 changes: 0 additions & 38 deletions apis_core/utils/helpers.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import difflib
import importlib
import inspect
import itertools
import logging


from apis_core.apis_relations.models import Property, TempTriple
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 009a871

Please sign in to comment.