def _get_module(target):
filepath, sep, namespace = target.rpartition('<STR_LIT:|>')<EOL>if sep and not filepath:<EOL><INDENT>raise BadDirectory("<STR_LIT>")<EOL><DEDENT>module, sep, class_or_function = namespace.rpartition('<STR_LIT::>')<EOL>if (sep and not module) or (filepath and not module):<EOL><INDENT>raise MissingModule("<STR_LIT>" %<EOL>(namespace, target))<EOL><DEDENT>if filepath and filepath not in sys.path:<EOL><INDENT>if not os.path.isdir(filepath):<EOL><INDENT>raise BadDirectory("<STR_LIT>" % filepath)<EOL><DEDENT>sys.path.append(filepath)<EOL><DEDENT>if not class_or_function:<EOL><INDENT>raise MissingMethodOrFunction(<EOL>"<STR_LIT>" % target)<EOL><DEDENT>if module:<EOL><INDENT>try:<EOL><INDENT>__import__(module)<EOL><DEDENT>except ImportError as e:<EOL><INDENT>raise ImportFailed("<STR_LIT>"<EOL>"<STR_LIT>" % (module, e))<EOL><DEDENT><DEDENT>klass, sep, function = class_or_function.rpartition('<STR_LIT:.>')<EOL>return module, klass, function<EOL>
Import a named class, module, method or function.

    Accepts these formats:
        ".../file/path|module_name:Class.method"
        ".../file/path|module_name:Class"
        ".../file/path|module_name:function"
        "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.