def prepare_modules(module_paths: list, available: dict) -> dict:
indexed = {}<EOL>for path in module_paths:<EOL><INDENT>if not os.path.exists(path) and path not in available:<EOL><INDENT>err = '<STR_LIT>' + path<EOL>error(err)<EOL><DEDENT>else:<EOL><INDENT>for f in os.listdir(path):<EOL><INDENT>mod_path = join(path, f)<EOL>if f in indexed:<EOL><INDENT>warning('<STR_LIT>' + indexed[f] + '<STR_LIT>' + mod_path)<EOL><DEDENT>indexed[f] = mod_path<EOL><DEDENT><DEDENT><DEDENT>return indexed<EOL>
Scan all paths for external modules and form key-value dict.
:param module_paths: list of external modules (either python packages or third-party scripts)
:param available: dict of all registered python modules (can contain python modules from module_paths)
:return: dict of external modules, where keys are filenames (same as stepnames) and values are the paths