def load_module_from_modpath(parts, path=None, use_sys=<NUM_LIT:1>):
if use_sys:<EOL><INDENT>try:<EOL><INDENT>return sys.modules["<STR_LIT:.>".join(parts)]<EOL><DEDENT>except KeyError:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>modpath = []<EOL>prevmodule = None<EOL>for part in parts:<EOL><INDENT>modpath.append(part)<EOL>curname = "<STR_LIT:.>".join(modpath)<EOL>module = None<EOL>if len(modpath) != len(parts):<EOL><INDENT>module = sys.modules.get(curname)<EOL><DEDENT>elif use_sys:<EOL><INDENT>module = sys.modules.get(curname)<EOL><DEDENT>if module is None:<EOL><INDENT>mp_file, mp_filename, mp_desc = imp.find_module(part, path)<EOL>module = imp.load_module(curname, mp_file, mp_filename, mp_desc)<EOL>if mp_file:<EOL><INDENT>mp_file.close()<EOL><DEDENT><DEDENT>if prevmodule:<EOL><INDENT>setattr(prevmodule, part, module)<EOL><DEDENT>_file = getattr(module, "<STR_LIT>", "<STR_LIT>")<EOL>prevmodule = module<EOL>if not _file and util.is_namespace(curname):<EOL><INDENT>continue<EOL><DEDENT>if not _file and len(modpath) != len(parts):<EOL><INDENT>raise ImportError("<STR_LIT>" % "<STR_LIT:.>".join(parts[len(modpath) :]))<EOL><DEDENT>path = [os.path.dirname(_file)]<EOL><DEDENT>return module<EOL>
Load a python module from its split name.

    :type parts: list(str) or tuple(str)
    :param parts:
      python name of a module or package split on '.'

    :type path: list or None
    :param path:
      optional list of path where the module or package should be
      searched (use sys.path if nothing or None is given)

    :type use_sys: bool
    :param use_sys:
      boolean indicating whether the sys.modules dictionary should be used or not

    :raise ImportError: if the module or package is not found

    :rtype: module
    :return: the loaded module