ansible_importer.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:ansible_importer 作者: nrb 项目源码 文件源码
def load_module(self, fullname):
        """
        Loads the source for a module found at `fullname`.

        For most of the module path here, we're going to be generating
        placeholders that don't actually have code; they'd be the equivalent of
        a bunch of empty dirs with __init__.py's, but ansible doesn't have the
        init file in the path.
        """
        if fullname in sys.modules:
            mod = sys.modules[fullname]
        else:
            mod = sys.modules.setdefault(fullname, imp.new_module(fullname))

        mod.__file__ = os.path.join(self.path, fullname)
        mod.__loader__ = self
        mod.__path__ = [self.path]
        mod.__package__ = '.'.join(fullname.split('.')[:-1])

        # We don't want to actually load unless we get to the Python code.
        # This is assuming that the guards in the __init__() function worked
        if self.basename not in ANSIBLE_DIRS and self.basename not in PLUGINS:
            mod = imp.load_source(self.basename, self.path + self.extension)
        return mod
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号