From 1211530baf28c6cc945cbc662b8d0bf8c42e5af6 Mon Sep 17 00:00:00 2001 From: ijgnd Date: Mon, 3 Feb 2020 02:13:14 +0100 Subject: [PATCH 1/5] Update CONTRIBUTORS --- CONTRIBUTORS | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 212b7082b..cd7a71e46 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -24,6 +24,7 @@ Erez Volk zjosua Arthur Milchior Yngve Hoiseth +ijgnd ******************** From de9331a03e0e5b3a88a3c30a247283cfc9d33e83 Mon Sep 17 00:00:00 2001 From: ijgnd Date: Mon, 3 Feb 2020 02:14:55 +0100 Subject: [PATCH 2/5] add human_version to manifest.json edit 7586c67 add human_version to manifest.json --- qt/aqt/addons.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/qt/aqt/addons.py b/qt/aqt/addons.py index 3a43acef9..4b252da3a 100644 --- a/qt/aqt/addons.py +++ b/qt/aqt/addons.py @@ -101,6 +101,7 @@ class AddonMeta: min_point_version: int max_point_version: int branch_index: int + human_version: Optional[str] def human_name(self) -> str: return self.provided_name or self.dir_name @@ -132,6 +133,7 @@ class AddonMeta: min_point_version=json_meta.get("min_point_version", 0) or 0, max_point_version=json_meta.get("max_point_version", 0) or 0, branch_index=json_meta.get("branch_index", 0) or 0, + human_version=json_meta.get("human_version", ""), ) @@ -157,6 +159,8 @@ class AddonManager: "max_point_version": {"type": "number", "meta": True}, # AnkiWeb sends this to indicate which branch the user downloaded. "branch_index": {"type": "number", "meta": True}, + # version string set by the add-on creator + "human_version": {"type": "string", "meta": True}, }, "required": ["package", "name"], } @@ -236,6 +240,8 @@ When loading '%(name)s': json_obj["max_point_version"] = addon.max_point_version json_obj["min_point_version"] = addon.min_point_version json_obj["branch_index"] = addon.branch_index + if addon.human_version is not None: + json_obj["human_version"] = addon.human_version self.writeAddonMeta(addon.dir_name, json_obj) From 6e1996f701690377df5e302c646c18b41f9fa19c Mon Sep 17 00:00:00 2001 From: ijgnd Date: Mon, 3 Feb 2020 02:17:10 +0100 Subject: [PATCH 3/5] Extend Copy Debug Info --- qt/aqt/about.py | 46 ++++++++++++++++++++++++++++++++++++++++++++-- qt/aqt/utils.py | 6 ++++++ 2 files changed, 50 insertions(+), 2 deletions(-) diff --git a/qt/aqt/about.py b/qt/aqt/about.py index e4416148d..b3aa7dee9 100644 --- a/qt/aqt/about.py +++ b/qt/aqt/about.py @@ -2,6 +2,7 @@ # -*- coding: utf-8 -*- # License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html import platform +import time import aqt.forms from anki.lang import _ @@ -32,10 +33,51 @@ def show(mw): # Copy debug info ###################################################################### + def addon_fmt(addmgr, a): + if a.installed_at: + t = time.strftime("%Y-%m-%dT%H:%M", time.localtime(a.installed_at)) + else: + t = "0" + if a.provided_name: + n = a.provided_name + else: + n = "''" + user = addmgr.getConfig(a.dir_name) + default = addmgr.addonConfigDefaults(a.dir_name) + if user == default: + confstat = "''" + else: + confstat = "mod" + return f"{n} ['{a.dir_name}', {t}, '{a.human_version}', {confstat}]" + def onCopy(): addmgr = mw.addonManager - addons = "\n".join(addmgr.annotatedName(d) for d in addmgr.allAddons()) - info = "\n".join((supportText(), "Add-ons:\n\n{}".format(addons))) + active = [] + activeids = [] + inactive = [] + for a in addmgr.all_addon_meta(): + if a.enabled: + active.append(addon_fmt(addmgr, a)) + if a.ankiweb_id(): + activeids.append(a.dir_name) + else: + inactive.append(addon_fmt(addmgr, a)) + newline = "\n" + info = f""" +{supportText()} + +===Add-ons (active)=== +(add-on provided name [Add-on folder, installed at, version, is config changed]) +{newline.join(sorted(active))} + +===Add-ons (active) Ankiweb-IDs=== +{" ".join(activeids)} + +===Add-ons (inactive)=== +(add-on provided name [Add-on folder, installed at, version, is config changed]) +{newline.join(sorted(inactive))} +""" + info = " " + " ".join(info.splitlines(True)) QApplication.clipboard().setText(info) tooltip(_("Copied to clipboard"), parent=dialog) diff --git a/qt/aqt/utils.py b/qt/aqt/utils.py index 9143636cd..318f48b07 100644 --- a/qt/aqt/utils.py +++ b/qt/aqt/utils.py @@ -685,6 +685,7 @@ def qtMenuShortcutWorkaround(qmenu): def supportText(): import platform + import time from aqt import mw if isWin: @@ -700,10 +701,14 @@ def supportText(): except: return "?" + lc = mw.pm.last_addon_update_check() + lcfmt = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(lc)) + return """\ Anki {} Python {} Qt {} PyQt {} Platform: {} Flags: frz={} ao={} sv={} +Add-ons, last update check: {} """.format( versionWithBuild(), platform.python_version(), @@ -713,6 +718,7 @@ Flags: frz={} ao={} sv={} getattr(sys, "frozen", False), mw.addonManager.dirty, schedVer(), + lcfmt, ) From 62527f0b544f6c560978930bbde80d0230b52c5c Mon Sep 17 00:00:00 2001 From: ijgnd <40218852+ijgnd@users.noreply.github.com> Date: Tue, 4 Feb 2020 02:46:57 +0100 Subject: [PATCH 4/5] about.py - some type hints --- qt/aqt/about.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/qt/aqt/about.py b/qt/aqt/about.py index b3aa7dee9..e6095ba60 100644 --- a/qt/aqt/about.py +++ b/qt/aqt/about.py @@ -7,6 +7,7 @@ import time import aqt.forms from anki.lang import _ from anki.utils import versionWithBuild +from aqt.addons import AddonManager, AddonMeta from aqt.qt import * from aqt.utils import supportText, tooltip @@ -33,7 +34,7 @@ def show(mw): # Copy debug info ###################################################################### - def addon_fmt(addmgr, a): + def addon_fmt(addmgr: AddonManager, a: AddonMeta) -> str: if a.installed_at: t = time.strftime("%Y-%m-%dT%H:%M", time.localtime(a.installed_at)) else: From 2c3b9ebe43f2893152f7602e8c4e4d08af3291a7 Mon Sep 17 00:00:00 2001 From: ijgnd <40218852+ijgnd@users.noreply.github.com> Date: Tue, 4 Feb 2020 02:48:51 +0100 Subject: [PATCH 5/5] Update CONTRIBUTORS --- CONTRIBUTORS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTORS b/CONTRIBUTORS index cd7a71e46..46a7c7720 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -24,7 +24,7 @@ Erez Volk zjosua Arthur Milchior Yngve Hoiseth -ijgnd +Ijgnd ********************