# Path: chemtrails/conf.py
# USER_SETTINGS = getattr(django_settings, 'CHEMTRAILS', None)
# DEFAULTS = {
#     'ENABLED': True,
#     'MAX_CONNECTION_DEPTH': 1,
#     'NAMED_RELATIONSHIPS': True,
#     'CONNECT_META_NODES': False,
#     'IGNORE_MODELS': [
#         'admin.logentry',
#         'migrations.migration',
#     ],
# }
# class CSettings:
#     def __init__(self, user_settings=None, defaults=None):
#     def __getattr__(self, attr):
#     def user_settings(self):
# def reload_settings(*args, **kwargs):
# 
# Path: chemtrails/utils.py
# def get_model_string(model):
#     """
#     :param model: model
#     :returns: <app_label>.<model_name> string representation for the model
#     """
#     return "{app_label}.{model_name}".format(app_label=model._meta.app_label, model_name=model._meta.model_name)
# 
# def flatten(sequence):
#     """
#     Flatten an arbitrary nested sequence.
#     Example usage:
#       >> my_list = list(flatten(nested_lists))
#     :param sequence: A nested list or tuple.
#     :returns: A generator with all values in a flat structure.
#     """
#     for i in sequence:
#         if isinstance(i, Sequence) and not isinstance(i, (str, bytes)):
#             yield from flatten(i)
#         else:
#             yield i
# 
# def timeit(func):
#     """
#     Decorator which logs the timing of executing a function
#     or method call to DEBUG logger.
#     """
#     @functools.wraps(func)
#     def f(*args, **kwargs):
#         timestamp = time.time()
#         func(*args, **kwargs)
#         logger.debug('function [{0}] executed in {1}s'.format(
#             f.__name__, '%.5f' % (time.time() - timestamp)
#         ))
#     return f


import itertools
import logging
import operator
        import csv
from collections import defaultdict, MutableMapping
from functools import reduce
from django.db import models
from django.db.models import Manager
from django.contrib.contenttypes.fields import GenericRelation, GenericForeignKey
from django.contrib.contenttypes.models import ContentType
from django.core.exceptions import ImproperlyConfigured, ValidationError, ObjectDoesNotExist
from django.contrib.postgres.fields import HStoreField, JSONField, RangeField
from django.utils.translation import ungettext
from neomodel import *
from chemtrails.conf import settings
from chemtrails.utils import get_model_string, flatten, timeit
        from chemtrails.neoutils import __node_cache__
        from chemtrails.conf import settings
        from chemtrails.neoutils.managers import PathManager
        from chemtrails.neoutils import (
            __meta_cache__, __node_cache__,
            get_node_class_for_model, get_meta_node_class_for_model
        )
            from chemtrails.neoutils import get_node_class_for_model
        from chemtrails.neoutils import get_node_for_object
        from chemtrails.neoutils import get_node_for_object
        from chemtrails.neoutils import __meta_cache__
        from chemtrails.neoutils import get_meta_node_for_model
    def has_relations(cls):
        return len(cls.__all_relationships__) > 0

    @property
    def paths(self):
        """
        Returns a ``PathManager`` object which can be used to build 
        traversal paths originating from this node.
        """
        return PathManager(self)

    @staticmethod
    def _log_relationship_definition(action: str, node, prop, level: int = 20):
        direction = {-1: 'INCOMING', 0: 'MUTUAL', 1: 'OUTGOING'}
        message = ('%(action)s %(direction)s relation %(relation_type)s '
                   'between %(klass)r and %(node)r' % {
                       'action': action,
                       'direction': direction[prop.definition['direction']],
                       'relation_type': prop.definition['relation_type'],
                       'klass': prop.source,
                       'node': node
                   })
        logger.log(level=level, msg=message)

    @staticmethod
    def _get_remote_field_name(field):
        reverse_field = True if isinstance(field, (
            models.ManyToManyRel, models.ManyToOneRel, models.OneToOneRel, GenericRelation)) else False

        return str('{model}.{field}'.format(

# Path: chemtrails/conf.py
# USER_SETTINGS = getattr(django_settings, 'CHEMTRAILS', None)
# DEFAULTS = {
#     'ENABLED': True,
#     'MAX_CONNECTION_DEPTH': 1,
#     'NAMED_RELATIONSHIPS': True,
#     'CONNECT_META_NODES': False,
#     'IGNORE_MODELS': [
#         'admin.logentry',
#         'migrations.migration',
#     ],
# }
# class CSettings:
#     def __init__(self, user_settings=None, defaults=None):
#     def __getattr__(self, attr):
#     def user_settings(self):
# def reload_settings(*args, **kwargs):
# 
# Path: chemtrails/utils.py
# def get_model_string(model):
#     """
#     :param model: model
#     :returns: <app_label>.<model_name> string representation for the model
#     """
#     return "{app_label}.{model_name}".format(app_label=model._meta.app_label, model_name=model._meta.model_name)
# 
# def flatten(sequence):
#     """
#     Flatten an arbitrary nested sequence.
#     Example usage:
#       >> my_list = list(flatten(nested_lists))
#     :param sequence: A nested list or tuple.
#     :returns: A generator with all values in a flat structure.
#     """
#     for i in sequence:
#         if isinstance(i, Sequence) and not isinstance(i, (str, bytes)):
#             yield from flatten(i)
#         else:
#             yield i
# 
# def timeit(func):
#     """
#     Decorator which logs the timing of executing a function
#     or method call to DEBUG logger.
#     """
#     @functools.wraps(func)
#     def f(*args, **kwargs):
#         timestamp = time.time()
#         func(*args, **kwargs)
#         logger.debug('function [{0}] executed in {1}s'.format(
#             f.__name__, '%.5f' % (time.time() - timestamp)
#         ))
#     return f


# Path: chemtrails/neoutils/core.py
import itertools
import logging
import operator
        import csv
from collections import defaultdict, MutableMapping
from functools import reduce
from django.db import models
from django.db.models import Manager
from django.contrib.contenttypes.fields import GenericRelation, GenericForeignKey
from django.contrib.contenttypes.models import ContentType
from django.core.exceptions import ImproperlyConfigured, ValidationError, ObjectDoesNotExist
from django.contrib.postgres.fields import HStoreField, JSONField, RangeField
from django.utils.translation import ungettext
from neomodel import *
from chemtrails.conf import settings
from chemtrails.utils import get_model_string, flatten, timeit
        from chemtrails.neoutils import __node_cache__
        from chemtrails.conf import settings
        from chemtrails.neoutils.managers import PathManager
        from chemtrails.neoutils import (
            __meta_cache__, __node_cache__,
            get_node_class_for_model, get_meta_node_class_for_model
        )
            from chemtrails.neoutils import get_node_class_for_model
        from chemtrails.neoutils import get_node_for_object
        from chemtrails.neoutils import get_node_for_object
        from chemtrails.neoutils import __meta_cache__
        from chemtrails.neoutils import get_meta_node_for_model

    def has_relations(cls):
        return len(cls.__all_relationships__) > 0

    @property
    def paths(self):
        """
        Returns a ``PathManager`` object which can be used to build 
        traversal paths originating from this node.
        """
        return PathManager(self)

    @staticmethod
    def _log_relationship_definition(action: str, node, prop, level: int = 20):
        direction = {-1: 'INCOMING', 0: 'MUTUAL', 1: 'OUTGOING'}
        message = ('%(action)s %(direction)s relation %(relation_type)s '
                   'between %(klass)r and %(node)r' % {
                       'action': action,
                       'direction': direction[prop.definition['direction']],
                       'relation_type': prop.definition['relation_type'],
                       'klass': prop.source,
                       'node': node
                   })
        logger.log(level=level, msg=message)

    @staticmethod
    def _get_remote_field_name(field):
        reverse_field = True if isinstance(field, (
            models.ManyToManyRel, models.ManyToOneRel, models.OneToOneRel, GenericRelation)) else False

        return str('{model}.{field}'.format(

            model=get_model_string(field.model),