mirror of
https://github.com/Hopiu/wagtail-modeltranslation.git
synced 2026-03-16 22:10:30 +00:00
22 lines
486 B
Python
22 lines
486 B
Python
# coding: utf-8
|
|
import inspect
|
|
|
|
|
|
def compare_class_tree_depth(model_class):
|
|
"""
|
|
Function to sort a list of class objects, where subclasses
|
|
have lower indices than their superclasses
|
|
"""
|
|
|
|
return -len(inspect.getmro(model_class))
|
|
|
|
|
|
def import_from_string(name):
|
|
"""
|
|
Returns a module from a string path
|
|
"""
|
|
components = name.split('.')
|
|
mod = __import__(components[0])
|
|
for comp in components[1:]:
|
|
mod = getattr(mod, comp)
|
|
return mod
|