connect.py 文件源码

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

项目:Playground3 作者: CrimsonVista 项目源码 文件源码
def reloadConnectors(self, force=False):
        if self._loaded and not force: return

        configPath = Configure.CurrentPath()
        connectorsLocation = os.path.join(configPath, "connectors")
        connectorsInitPath = os.path.join(connectorsLocation, "__init__.py")

        oldPath = sys.path
        if configPath not in sys.path:
            sys.path.insert(0, configPath)
        if not os.path.exists(connectorsInitPath):
            with open(connectorsInitPath, "w+") as f:
                f.write("#dummy init for connectors module")

        for pathName in os.listdir(connectorsLocation):
            pathName = os.path.join(connectorsLocation, pathName)
            moduleName = os.path.basename(pathName)
            if os.path.exists(os.path.join(pathName, "__init__.py")):
                dottedName = "connectors.{}".format(moduleName)
                with PacketDefinitionSilo():
                    if dottedName in sys.modules:
                        #TODO: Test if this even works.
                        importlib.reload(sys.module[dottedName])
                    else:
                        importlib.import_module(dottedName)
        sys.path = oldPath
        self._loaded = True
        #    print("Loading module {}".format(pathName))
        #    self._loadConnectorModule(os.path.join(connectorLocation, pathName))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号