loader.py 文件源码

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

项目:inmanta 作者: inmanta 项目源码 文件源码
def load_modules(self):
        """
            Load all existing modules
        """
        mod_dir = os.path.join(self.__code_dir, MODULE_DIR)

        if os.path.exists(os.path.join(self.__code_dir, VERSION_FILE)):
            fd = open(os.path.join(self.__code_dir, VERSION_FILE), "r")
            self.__current_version = int(fd.read())
            fd.close()

        pkg_resources.working_set = pkg_resources.WorkingSet._build_master()

        for py in glob.glob(os.path.join(mod_dir, "*.py")):
            if mod_dir in py:
                mod_name = py[len(mod_dir) + 1:-3]
            else:
                mod_name = py[:-3]

            source_code = ""
            with open(py, "r") as fd:
                source_code = fd.read().encode("utf-8")

            sha1sum = hashlib.new("sha1")
            sha1sum.update(source_code)

            hv = sha1sum.hexdigest()

            self._load_module(mod_name, py, hv)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号