def get_mod_subcmds(mod):
    """Fetch action in same directory in python module

    python module loaded are of this form: '%s_*.py' % prefix

    """

    ## Look in modules attributes

    subcmds = get_obj_subcmds(mod)

    path = os.path.dirname(os.path.realpath(mod.__file__))
    if mod.__package__ is None:
        sys.path.insert(0, os.path.dirname(path))
        mod.__package__ = kf.basename(path)

    for module_name in get_module_resources(mod):
        try:
            mod = importlib.import_module(".%s" % module_name, mod.__package__)
        except ImportError as e:
            msg.warn("%r could not be loaded: %s"
                     % (module_name, e.message))
            continue
        except IOError as e:
            print("%s" % module_name)
            raise
        if hasattr(mod, "Command") and is_cmd(mod.Command):
            obj = mod.Command
            if obj.__doc__ is None:
                msg.warn("Missing doc string for command from "
                         "module %s" % module_name)
                continue
            if isinstance(obj, type):
                obj = obj()  ## instanciate it.
            name = module_name.split("_", 1)[1]
            if name in subcmds:
                raise ValueError(
                    "Module command %r conflicts with already defined object "
                    "command."
                    % name)
            subcmds[name] = obj

    return subcmds
Fetch action in same directory in python module

    python module loaded are of this form: '%s_*.py' % prefix