MCPcopy
hub / github.com/hylang/hy / get_compiler_module

Function get_compiler_module

hy/compiler.py:712–728  ·  view source on GitHub ↗

Get a module object from a compiler, given module object, string name of a module, and (optionally) the calling frame; otherwise, raise an error.

(module=None, compiler=None, calling_frame=False)

Source from the content-addressed store, hash-verified

710
711
712def get_compiler_module(module=None, compiler=None, calling_frame=False):
713 """Get a module object from a compiler, given module object,
714 string name of a module, and (optionally) the calling frame; otherwise,
715 raise an error."""
716
717 module = getattr(compiler, "module", None) or module
718
719 if isinstance(module, str):
720 module = importlib.import_module(mangle(module))
721
722 if calling_frame and not module:
723 module = calling_module(n=2)
724
725 if not inspect.ismodule(module):
726 raise TypeError("Invalid module type: {}".format(type(module)))
727
728 return module
729
730
731def hy_eval(

Callers 3

hy_evalFunction · 0.85
hy_eval_userFunction · 0.85
hy_compileFunction · 0.85

Calls 2

mangleFunction · 0.90
calling_moduleFunction · 0.85

Tested by

no test coverage detected