def my_handle_update_info( parent: QWidget, mgr: AddonManager, client: HttpClient, items: List[Dict], on_done: Callable[[List[DownloadLogEntry]], None], ) -> None: global today_candidates # empty it in case I run updates twice in a row while the add-on manager window is open today_candidates = {} update_info = mgr.extract_update_info(items) mgr.update_supported_versions(update_info) updated_ids = mgr.updates_required(update_info) for f in updated_ids: for ui in update_info: if f == ui.id: stamp = ui.suitable_branch_last_modified creatorname = creator_for_nids.get(str(f), "") if creatorname: creatorname += ", " lbl = f"{mgr.addonName(str(f))} ({creatorname}{date_fmted(stamp)})" today_candidates[f] = [stamp, lbl] if not updated_ids: on_done([]) return my_prompt_to_update(parent, mgr, client, updated_ids, on_done)
def assertReadManifest(contents, expectedManifest, nameInZip="manifest.json"): with TemporaryDirectory() as td: zfn = os.path.join(td, "addon.zip") with ZipFile(zfn, "w") as zfile: zfile.writestr(nameInZip, contents) adm = AddonManager(MagicMock()) with ZipFile(zfn, "r") as zfile: assert_equals(adm.readManifestFile(zfile), expectedManifest)
def addon_fmt(addmgr: AddonManager, addon: AddonMeta) -> str: if addon.installed_at: installed = time.strftime("%Y-%m-%dT%H:%M", time.localtime(addon.installed_at)) else: installed = "0" if addon.provided_name: name = addon.provided_name else: name = "''" user = addmgr.getConfig(addon.dir_name) default = addmgr.addonConfigDefaults(addon.dir_name) if user == default: modified = "''" else: modified = "mod" return f"{name} ['{addon.dir_name}', {installed}, '{addon.human_version}', {modified}]"