Lines Matching refs:mod_name
26 def __init__(self, mod_name): argument
27 self.mod_name = mod_name
28 self.module = types.ModuleType(mod_name)
32 mod_name = self.mod_name
34 self._saved_module.append(sys.modules[mod_name])
37 sys.modules[mod_name] = self.module
42 sys.modules[self.mod_name] = self._saved_module[0]
44 del sys.modules[self.mod_name]
64 mod_name=None, mod_spec=None, argument
79 run_globals.update(__name__ = mod_name,
90 mod_name=None, mod_spec=None, argument
94 with _TempModule(mod_name) as temp_module, _ModifiedArgv0(fname):
97 mod_name, mod_spec, pkg_name, script_name)
103 def _get_module_details(mod_name, error=ImportError): argument
104 if mod_name.startswith("."):
106 pkg_name, _, _ = mod_name.rpartition(".")
119 existing = sys.modules.get(mod_name)
125 "behaviour".format(mod_name=mod_name, pkg_name=pkg_name)
129 spec = importlib.util.find_spec(mod_name)
135 if mod_name.endswith(".py"):
138 raise error(msg.format(mod_name, type(ex).__name__, ex)) from ex
140 raise error("No module named %s" % mod_name)
142 if mod_name == "__main__" or mod_name.endswith(".__main__"):
145 pkg_main_name = mod_name + ".__main__"
148 if mod_name not in sys.modules:
151 "be directly executed") %(e, mod_name))
155 % mod_name)
157 code = loader.get_code(mod_name)
161 raise error("No code object available for %s" % mod_name)
162 return mod_name, spec, code
171 def _run_module_as_main(mod_name, alter_argv=True): argument
186 if alter_argv or mod_name != "__main__": # i.e. -m switch
187 mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
189 mod_name, mod_spec, code = _get_main_module_details(_Error)
199 def run_module(mod_name, init_globals=None, argument
205 mod_name, mod_spec, code = _get_module_details(mod_name)
207 run_name = mod_name
282 mod_name, mod_spec, code = _get_main_module_details()