1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
|
Description: Adopt to new keyring API
Update Kupfer plugin support code to work with modern python-keyring versions:
.
* Use priority property for a rough check if the keyring is encrypted.
* Use __doc__ to get the human-readable keyring name.
* Use filename attribute to set the filename for file-based backends.
Author: Sebastian Ramacher <sramacher@debian.org>
Author: Dmitry Shachnev <mitya57@debian.org>
Bug-Debian: http://bugs.debian.org/728468
Last-Update: 2016-02-07
--- a/kupfer/plugin_support.py
+++ b/kupfer/plugin_support.py
@@ -160,21 +160,14 @@
@classmethod
def is_backend_encrypted(cls):
- import keyring.core
- return keyring.core.get_keyring().supported() == 1
+ import keyring
+ # Plaintext keyring backend has priority 0.5, other ones have higher
+ return keyring.get_keyring().priority > 0.5
@classmethod
def get_backend_name(cls):
- import keyring.core
- import keyring.backend
- keyring_map = {
- keyring.backend.GnomeKeyring : _("GNOME Keyring"),
- keyring.backend.KDEKWallet : _("KWallet"),
- keyring.backend.UncryptedFileKeyring: _("Unencrypted File"),
- }
- kr = keyring.get_keyring()
- keyring_name = keyring_map.get(type(kr), type(kr).__name__)
- return keyring_name
+ import keyring
+ return keyring.get_keyring().__doc__
def load(self, plugin_id, key, username):
self.password = keyring.get_password(plugin_id, username)
@@ -209,13 +202,9 @@
raise
else:
# Configure the fallback keyring's configuration file if used
- import keyring.backend
kr = keyring.get_keyring()
- if hasattr(kr, "crypted_password"):
- keyring.set_keyring(keyring.backend.UncryptedFileKeyring())
- kr = keyring.get_keyring()
- if hasattr(kr, "file_path"):
- kr.file_path = config.save_config_file("keyring.cfg")
+ if hasattr(kr, "filename"):
+ kr.filename = config.save_config_file("keyring.cfg")
finally:
# now unblock kde libraries again
if old_pykde4:
|