Utilities

elasticgit.utils.fqcn(klass)[source]

Given a class give it’s fully qualified class name in dotted notation. The inverse of load_class

Parameters:klass (class) –
>>> from elasticgit.utils import fqcn
>>> from elasticgit.tests.base import TestPerson
>>> fqcn(TestPerson)
'elasticgit.tests.base.TestPerson'
>>>
elasticgit.utils.introspect_properties(model_class)[source]

Introspect a elasticgit.models.Model and retrieve a suitable mapping to use when indexing instances of the model in Elasticsearch.

>>> from elasticgit.models import Model, TextField
>>>
>>> class TestModel(Model):
...     field = TextField('A text field')
...
>>> from elasticgit.utils import introspect_properties
>>>
>>> sorted(introspect_properties(TestModel).keys()) 
['_version', 'field', 'uuid']
>>>
elasticgit.utils.load_class(class_path)[source]

Load a class by it’s class path

Parameters:class_path (str) – The dotted.path.to.TheClass
>>> from elasticgit.utils import load_class
>>> load_class('elasticgit.tests.base.TestPerson')
<class 'elasticgit.tests.base.TestPerson'>
>>>