Python imp.get_loader() Examples
The following are 15
code examples of imp.get_loader().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
imp
, or try the search function
.
Example #1
Source File: runpy.py From ironpython2 with Apache License 2.0 | 6 votes |
def _get_module_details(mod_name, error=ImportError): try: loader = get_loader(mod_name) if loader is None: raise error("No module named %s" % mod_name) ispkg = loader.is_package(mod_name) except ImportError as e: raise error(format(e)) if ispkg: if mod_name == "__main__" or mod_name.endswith(".__main__"): raise error("Cannot use package as __main__ module") __import__(mod_name) # Do not catch exceptions initializing package try: pkg_main_name = mod_name + ".__main__" return _get_module_details(pkg_main_name) except ImportError, e: raise error(("%s; %r is a package and cannot " + "be directly executed") %(e, mod_name))
Example #2
Source File: runpy.py From medicare-demo with Apache License 2.0 | 6 votes |
def run_module(mod_name, init_globals=None, run_name=None, alter_sys=False): """Execute a module's code without importing it Returns the resulting top level namespace dictionary """ loader = get_loader(mod_name) if loader is None: raise ImportError("No module named " + mod_name) code = loader.get_code(mod_name) if code is None: raise ImportError("No code object available for " + mod_name) filename = _get_filename(loader, mod_name) if run_name is None: run_name = mod_name return _run_module_code(code, init_globals, run_name, filename, loader, alter_sys)
Example #3
Source File: runpy.py From PokemonGo-DesktopMap with MIT License | 6 votes |
def _get_module_details(mod_name, error=ImportError): try: loader = get_loader(mod_name) if loader is None: raise error("No module named %s" % mod_name) ispkg = loader.is_package(mod_name) except ImportError as e: raise error(format(e)) if ispkg: if mod_name == "__main__" or mod_name.endswith(".__main__"): raise error("Cannot use package as __main__ module") __import__(mod_name) # Do not catch exceptions initializing package try: pkg_main_name = mod_name + ".__main__" return _get_module_details(pkg_main_name) except ImportError, e: raise error(("%s; %r is a package and cannot " + "be directly executed") %(e, mod_name))
Example #4
Source File: runpy.py From unity-python with MIT License | 6 votes |
def _get_module_details(mod_name, error=ImportError): try: loader = get_loader(mod_name) if loader is None: raise error("No module named %s" % mod_name) ispkg = loader.is_package(mod_name) except ImportError as e: raise error(format(e)) if ispkg: if mod_name == "__main__" or mod_name.endswith(".__main__"): raise error("Cannot use package as __main__ module") __import__(mod_name) # Do not catch exceptions initializing package try: pkg_main_name = mod_name + ".__main__" return _get_module_details(pkg_main_name) except ImportError, e: raise error(("%s; %r is a package and cannot " + "be directly executed") %(e, mod_name))
Example #5
Source File: runpy.py From meddle with MIT License | 5 votes |
def _get_module_details(mod_name): loader = get_loader(mod_name) if loader is None: raise ImportError("No module named %s" % mod_name) if loader.is_package(mod_name): if mod_name == "__main__" or mod_name.endswith(".__main__"): raise ImportError("Cannot use package as __main__ module") try: pkg_main_name = mod_name + ".__main__" return _get_module_details(pkg_main_name) except ImportError, e: raise ImportError(("%s; %r is a package and cannot " + "be directly executed") %(e, mod_name))
Example #6
Source File: runpy.py From BinderFilter with MIT License | 5 votes |
def _get_module_details(mod_name): loader = get_loader(mod_name) if loader is None: raise ImportError("No module named %s" % mod_name) if loader.is_package(mod_name): if mod_name == "__main__" or mod_name.endswith(".__main__"): raise ImportError("Cannot use package as __main__ module") try: pkg_main_name = mod_name + ".__main__" return _get_module_details(pkg_main_name) except ImportError, e: raise ImportError(("%s; %r is a package and cannot " + "be directly executed") %(e, mod_name))
Example #7
Source File: runpy.py From oss-ftp with MIT License | 5 votes |
def _get_module_details(mod_name): loader = get_loader(mod_name) if loader is None: raise ImportError("No module named %s" % mod_name) if loader.is_package(mod_name): if mod_name == "__main__" or mod_name.endswith(".__main__"): raise ImportError("Cannot use package as __main__ module") try: pkg_main_name = mod_name + ".__main__" return _get_module_details(pkg_main_name) except ImportError, e: raise ImportError(("%s; %r is a package and cannot " + "be directly executed") %(e, mod_name))
Example #8
Source File: runpy.py From scoop with GNU Lesser General Public License v3.0 | 5 votes |
def _get_module_details(mod_name): loader = get_loader(mod_name) if loader is None: raise ImportError("No module named %s" % mod_name) if loader.is_package(mod_name): if mod_name == "__main__" or mod_name.endswith(".__main__"): raise ImportError("Cannot use package as __main__ module") try: pkg_main_name = mod_name + ".__main__" return _get_module_details(pkg_main_name) except ImportError, e: raise ImportError(("%s; %r is a package and cannot " + "be directly executed") %(e, mod_name))
Example #9
Source File: runpy.py From Splunking-Crime with GNU Affero General Public License v3.0 | 5 votes |
def _get_module_details(mod_name): loader = get_loader(mod_name) if loader is None: raise ImportError("No module named %s" % mod_name) if loader.is_package(mod_name): if mod_name == "__main__" or mod_name.endswith(".__main__"): raise ImportError("Cannot use package as __main__ module") try: pkg_main_name = mod_name + ".__main__" return _get_module_details(pkg_main_name) except ImportError, e: raise ImportError(("%s; %r is a package and cannot " + "be directly executed") %(e, mod_name))
Example #10
Source File: runpy.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
def _get_module_details(mod_name): loader = get_loader(mod_name) if loader is None: raise ImportError("No module named %s" % mod_name) if loader.is_package(mod_name): if mod_name == "__main__" or mod_name.endswith(".__main__"): raise ImportError("Cannot use package as __main__ module") try: pkg_main_name = mod_name + ".__main__" return _get_module_details(pkg_main_name) except ImportError, e: raise ImportError(("%s; %r is a package and cannot " + "be directly executed") %(e, mod_name))
Example #11
Source File: runpy.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
def _get_module_details(mod_name): loader = get_loader(mod_name) if loader is None: raise ImportError("No module named %s" % mod_name) if loader.is_package(mod_name): if mod_name == "__main__" or mod_name.endswith(".__main__"): raise ImportError("Cannot use package as __main__ module") try: pkg_main_name = mod_name + ".__main__" return _get_module_details(pkg_main_name) except ImportError, e: raise ImportError(("%s; %r is a package and cannot " + "be directly executed") %(e, mod_name))
Example #12
Source File: runpy.py From RevitBatchProcessor with GNU General Public License v3.0 | 5 votes |
def _get_module_details(mod_name): loader = get_loader(mod_name) if loader is None: raise ImportError("No module named %s" % mod_name) if loader.is_package(mod_name): if mod_name == "__main__" or mod_name.endswith(".__main__"): raise ImportError("Cannot use package as __main__ module") try: pkg_main_name = mod_name + ".__main__" return _get_module_details(pkg_main_name) except ImportError, e: raise ImportError(("%s; %r is a package and cannot " + "be directly executed") %(e, mod_name))
Example #13
Source File: runpy.py From canape with GNU General Public License v3.0 | 5 votes |
def _get_module_details(mod_name): loader = get_loader(mod_name) if loader is None: raise ImportError("No module named %s" % mod_name) if loader.is_package(mod_name): if mod_name == "__main__" or mod_name.endswith(".__main__"): raise ImportError("Cannot use package as __main__ module") try: pkg_main_name = mod_name + ".__main__" return _get_module_details(pkg_main_name) except ImportError, e: raise ImportError(("%s; %r is a package and cannot " + "be directly executed") %(e, mod_name))
Example #14
Source File: runpy.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
def _get_module_details(mod_name): loader = get_loader(mod_name) if loader is None: raise ImportError("No module named %s" % mod_name) if loader.is_package(mod_name): if mod_name == "__main__" or mod_name.endswith(".__main__"): raise ImportError("Cannot use package as __main__ module") try: pkg_main_name = mod_name + ".__main__" return _get_module_details(pkg_main_name) except ImportError, e: raise ImportError(("%s; %r is a package and cannot " + "be directly executed") %(e, mod_name))
Example #15
Source File: runpy.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
def _get_module_details(mod_name): loader = get_loader(mod_name) if loader is None: raise ImportError("No module named %s" % mod_name) if loader.is_package(mod_name): if mod_name == "__main__" or mod_name.endswith(".__main__"): raise ImportError("Cannot use package as __main__ module") try: pkg_main_name = mod_name + ".__main__" return _get_module_details(pkg_main_name) except ImportError, e: raise ImportError(("%s; %r is a package and cannot " + "be directly executed") %(e, mod_name))