This is a class global method to enforce the dependencies that you
        currently know about.
        It will modify the "functions" dict and remove/replace modules that
        are missing dependencies.

def enforce_dependencies(cls, functions, kind):
        '''
        This is a class global method to enforce the dependencies that you
        currently know about.
        It will modify the "functions" dict and remove/replace modules that
        are missing dependencies.
        '''
        for dependency, dependent_dict in six.iteritems(cls.dependency_dict[kind]):
            for (mod_name, func_name), (frame, params) in six.iteritems(dependent_dict):
                if 'retcode' in params or 'nonzero_retcode' in params:
                    try:
                        retcode = cls.run_command(dependency, mod_name, func_name)
                    except OSError as exc:
                        if exc.errno == errno.ENOENT:
                            log.trace(
                                'Failed to run command %s, %s not found',
                                dependency, exc.filename
                            )
                        else:
                            log.trace(
                                'Failed to run command \'%s\': %s', dependency, exc
                            )
                        retcode = -1

                    if 'retcode' in params:
                        if params['retcode'] == retcode:
                            continue

                    elif 'nonzero_retcode' in params:
                        if params['nonzero_retcode']:
                            if retcode != 0:
                                continue
                        else:
                            if retcode == 0:
                                continue

                # check if dependency is loaded
                elif dependency is True:
                    log.trace(
                        'Dependency for %s.%s exists, not unloading',
                        mod_name, func_name
                    )
                    continue

                # check if you have the dependency
                elif dependency in frame.f_globals \
                        or dependency in frame.f_locals:
                    log.trace(
                        'Dependency (%s) already loaded inside %s, skipping',
                        dependency, mod_name
                    )
                    continue

                log.trace(
                    'Unloading %s.%s because dependency (%s) is not met',
                    mod_name, func_name, dependency
                )
                # if not, unload the function
                if frame:
                    try:
                        func_name = frame.f_globals['__func_alias__'][func_name]
                    except (AttributeError, KeyError):
                        pass

                    mod_key = '{0}.{1}'.format(mod_name, func_name)

                    # if we don't have this module loaded, skip it!
                    if mod_key not in functions:
                        continue

                    try:
                        fallback_function = params.get('fallback_function')
                        if fallback_function is not None:
                            functions[mod_key] = fallback_function
                        else:
                            del functions[mod_key]
                    except AttributeError:
                        # we already did???
                        log.trace('%s already removed, skipping', mod_key)
                        continue