<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _get_module(target):
 """Import a named class, module, method or function. Accepts these formats: "module_name:Class" "module_name:function" "module_name:Class.function" If a fully qualified directory is specified, it implies the directory is not already on the Python Path, in which case it will be added. For example, if I import /home/foo (and /home/foo is not in the python path) as "/home/foo|mycode:MyClass.mymethod" then /home/foo will be added to the python path and the module loaded as normal. """


    filepath, sep, namespace = target.rpartition('|')
    if sep and not filepath:
        raise BadDirectory("Path to file not supplied.")

    module, sep, class_or_function = namespace.rpartition(':')
    if (sep and not module) or (filepath and not module):
        raise MissingModule("Need a module path for %s (%s)" %
                            (namespace, target))

    if filepath and filepath not in sys.path:
        if not os.path.isdir(filepath):
            raise BadDirectory("No such directory: '%s'" % filepath)
        sys.path.append(filepath)

    if not class_or_function:
        raise MissingMethodOrFunction(
            "No Method or Function specified in '%s'" % target)

    if module:
        try:
            __import__(module)
        except ImportError as e:
            raise ImportFailed("Failed to import '%s'. "
                               "Error: %s" % (module, e))

    klass, sep, function = class_or_function.rpartition('.')
    return module, klass, function