def update_list() -> list: modules_list = [] for module, isRunning in LOAD_MODULES.items(): if not module == basename(__file__)[:-3]: # exclude this module if module in USER_MODULES: if module in MODULE_INFO.keys(): # Append [Name of module, filename of module, running] -> [] modules_list.append([ MODULE_INFO.get(module, {}).get("name", msgRep.UNKNOWN), module, isRunning ]) else: modules_list.append([module, module, isRunning]) else: if module in MODULE_INFO.keys(): modules_list.append([ MODULE_INFO.get(module, {}).get("name", msgRep.UNKNOWN), module, isRunning ]) else: modules_list.append([module, module, isRunning]) global MODULES_LISTED if MODULES_LISTED: MODULES_LISTED = {} # reset dict num = 0 for module in [modules[1] for modules in sorted(modules_list)]: num += 1 MODULES_LISTED[str(num)] = module return sorted(modules_list)
def module_info(name_of_module: str, module: str) -> str: if module in getLoadModules().keys(): package_name, moduletype, installation_date = (msgRep.UNKNOWN,)*3 size = 0 if module in getModuleInfo().keys(): authors = getModuleInfo().get(module, {}).get("authors", msgRep.UNKNOWN) version = getModuleInfo().get(module, {}).get("version", 0) elif module in MODULE_INFO.keys(): log.info(f"MODULE_INFO is obsolete, please use register_module_info() instead (in module '{module}')") authors = MODULE_INFO.get(module, {}).get("authors", msgRep.UNKNOWN) version = MODULE_INFO.get(module, {}).get("version", 0) if not authors: authors = msgRep.UNKNOWN if not version: version = 0 package_name = module module += ".py" syspath = join(".", "userbot", "modules") userpath = join(".", "userbot", "modules_user") if exists(join(syspath, module)): moduletype = msgRep.SYSTEM size = sizeStrMaker(getsize(join(syspath, module))) if OS and OS.lower().startswith("win"): installation_date = getctime(join(syspath, module)) elif OS and OS.lower().startswith("darwin"): installation_date = stat(join(syspath, module)).st_birthtime else: installation_date = stat(join(syspath, module)).st_ctime elif exists(join(userpath, module)): moduletype = msgRep.USER size = sizeStrMaker(getsize(join(userpath, module))) if OS and OS.lower().startswith("win"): installation_date = getctime(join(userpath, module)) elif OS and OS.lower().startswith("darwin"): installation_date = stat(join(userpath, module)).st_birthtime else: installation_date = stat(join(userpath, module)).st_ctime result = f"{msgRep.PKG_NAME}: {package_name}\n" result += f"{msgRep.MODULE_TYPE}: {moduletype}\n" result += f"{msgRep.AUTHORS}: {authors}\n" result += f"{msgRep.VERSION}: {version}\n" result += f"{msgRep.SIZE}: {size}\n" result += f"{msgRep.INSTALL_DATE}: {ctime(installation_date)}" return msgRep.NAME_MODULE.format(name_of_module) + "\n\n" + result else: raise IndexError
def module_info(name_of_module: str, module: str) -> str: if module in LOAD_MODULES: package_name, moduletype, installation_date = (msgRep.UNKNOWN, ) * 3 size = 0 version = MODULE_INFO.get(module, {}).get("version", 0) package_name = module module += ".py" if OS and OS.lower().startswith("win"): syspath = ".\\userbot\\modules\\" userpath = ".\\userbot\\modules_user\\" else: syspath = "./userbot/modules/" userpath = "./userbot/modules_user/" if exists(syspath + module): moduletype = msgRep.SYSTEM size = sizeStrMaker(getsize(syspath + module)) if OS and OS.lower().startswith("win"): installation_date = getctime(syspath + module) elif OS and OS.lower().startswith("darwin"): installation_date = stat(syspath + module).st_birthtime else: installation_date = stat(syspath + module).st_ctime elif exists(userpath + module): moduletype = msgRep.USER size = sizeStrMaker(getsize(userpath + module)) if OS and OS.lower().startswith("win"): installation_date = getctime(userpath + module) elif OS and OS.lower().startswith("darwin"): installation_date = stat(userpath + module).st_birthtime else: installation_date = stat(userpath + module).st_ctime result = f"{msgRep.PKG_NAME}: {package_name}\n" result += f"{msgRep.MODULE_TYPE}: {moduletype}\n" result += f"{msgRep.VERSION}: {version}\n" result += f"{msgRep.SIZE}: {size}\n" result += f"{msgRep.INSTALL_DATE}: {ctime(installation_date)}" return msgRep.NAME_MODULE.format(name_of_module) + "\n\n" + result else: raise IndexError