1 Star 0 Fork 0

lysgwl/AppHelper

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
appfactory.py 1.01 KB
一键复制 编辑 原始数据 按行查看 历史
lysgwl 提交于 2023-11-12 20:46 . 2023.11.12 20:45
# -*- coding: UTF-8 -*-
from alistmodule import AlistModule
from aria2module import Aria2Module
# 应用工厂
class AppFactory:
__instance = None
@staticmethod
def getInstance():
if AppFactory.__instance is None:
AppFactory()
return AppFactory.__instance
def __init__(self):
self.applist = {}
if AppFactory.__instance is not None:
raise Exception("This class is a singleton!")
else:
AppFactory.__instance = self
def createAppModule(self, apptype, config):
app_types = {
config.AppType.ALIST_TYPE: AlistModule,
config.AppType.ARIA2_TYPE: Aria2Module
}
appobj = app_types.get(apptype)
if appobj:
appobj = appobj(config)
self.applist[apptype] = appobj
return appobj
def getAppModule(self, apptype):
if apptype is not None:
return self.applist[apptype]
else:
return self.applist.values()
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/c95wl/app-helper.git
git@gitee.com:c95wl/app-helper.git
c95wl
app-helper
AppHelper
master

搜索帮助

23e8dbc6 1850385 7e0993f3 1850385