From 8c3390106a61c85a0e2d77a0a83d068e5fff0397 Mon Sep 17 00:00:00 2001 From: Robert Sanek Date: Sat, 1 Dec 2018 08:13:38 -0800 Subject: [PATCH] Add API endpoint to load a profile If this needs tests please let me know --- AnkiConnect.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/AnkiConnect.py b/AnkiConnect.py index 605dd21..e943e93 100644 --- a/AnkiConnect.py +++ b/AnkiConnect.py @@ -507,6 +507,23 @@ class AnkiConnect: return False + @api() + def loadProfile(self, name): + if not self.window().isVisible(): + self.window().pm.load(name) + self.window().loadProfile() + self.window().profileDiag.closeWithoutQuitting() + return "Loaded profile {}.".format(name) + else: + cur_profile = self.window().pm.name + if cur_profile != name: + self.window().unloadProfileAndShowProfileManager() + self.loadProfile(name) + return "Switched from profile {} to profile {}.".format(cur_profile, name) + else: + return "Profile {} already loaded.".format(name) + + @api() def sync(self): self.window().onSync()