summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--keymanager/src/leap/keymanager/__init__.py4
-rw-r--r--keymanager/src/leap/keymanager/keys.py10
-rw-r--r--keymanager/src/leap/keymanager/openpgp.py8
-rw-r--r--keymanager/src/leap/keymanager/tests/test_keymanager.py2
4 files changed, 10 insertions, 14 deletions
diff --git a/keymanager/src/leap/keymanager/__init__.py b/keymanager/src/leap/keymanager/__init__.py
index f72f403..32e5581 100644
--- a/keymanager/src/leap/keymanager/__init__.py
+++ b/keymanager/src/leap/keymanager/__init__.py
@@ -81,7 +81,7 @@ from leap.keymanager.keys import (
KEYMANAGER_KEY_TAG,
TAGS_PRIVATE_INDEX,
)
-from leap.keymanager.openpgp import OpenPGPKey, OpenPGPScheme
+from leap.keymanager.openpgp import OpenPGPScheme
__version__ = get_versions()['version']
del get_versions
@@ -434,7 +434,7 @@ class KeyManager(object):
# TODO: should it be based on activedocs?
def build_keys(docs):
return map(
- lambda doc: build_key_from_dict(OpenPGPKey, doc.content),
+ lambda doc: build_key_from_dict(doc.content),
docs)
# XXX: there is no check that the soledad indexes are ready, as it
diff --git a/keymanager/src/leap/keymanager/keys.py b/keymanager/src/leap/keymanager/keys.py
index 1d03945..296ed86 100644
--- a/keymanager/src/leap/keymanager/keys.py
+++ b/keymanager/src/leap/keymanager/keys.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# keys.py
-# Copyright (C) 2013 LEAP
+# Copyright (C) 2013-2016 LEAP
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -14,8 +14,6 @@
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-
"""
Abstact key type and encryption scheme representations.
"""
@@ -116,9 +114,9 @@ def is_address(address):
return bool(re.match('[\w.-]+@[\w.-]+', address))
-def build_key_from_dict(kClass, key, active=None):
+def build_key_from_dict(key, active=None):
"""
- Build an C{kClass} key based on info in C{kdict}.
+ Build an OpenPGPKey key based on info in C{kdict}.
:param key: Dictionary with key data.
:type key: dict
@@ -148,7 +146,7 @@ def build_key_from_dict(kClass, key, active=None):
expiry_date = _to_datetime(key[KEY_EXPIRY_DATE_KEY])
refreshed_at = _to_datetime(key[KEY_REFRESHED_AT_KEY])
- return kClass(
+ return OpenPGPKey(
address=address,
uids=key[KEY_UIDS_KEY],
fingerprint=key[KEY_FINGERPRINT_KEY],
diff --git a/keymanager/src/leap/keymanager/openpgp.py b/keymanager/src/leap/keymanager/openpgp.py
index f8cc976..fae5600 100644
--- a/keymanager/src/leap/keymanager/openpgp.py
+++ b/keymanager/src/leap/keymanager/openpgp.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# openpgp.py
-# Copyright (C) 2013-2015 LEAP
+# Copyright (C) 2013-2016 LEAP
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -232,8 +232,7 @@ class OpenPGPScheme(object):
'Wrong address in key %s. Expected %s, found %s.'
% (keydoc.content[KEY_FINGERPRINT_KEY], address,
keydoc.content[KEY_UIDS_KEY]))
- key = build_key_from_dict(OpenPGPKey, keydoc.content,
- activedoc.content)
+ key = build_key_from_dict(keydoc.content, activedoc.content)
key._gpgbinary = self._gpgbinary
return key
@@ -328,8 +327,7 @@ class OpenPGPScheme(object):
active_content = None
if activedoc:
active_content = activedoc.content
- oldkey = build_key_from_dict(OpenPGPKey, keydoc.content,
- active_content)
+ oldkey = build_key_from_dict(keydoc.content, active_content)
key.merge(oldkey)
keydoc.set_json(key.get_json())
diff --git a/keymanager/src/leap/keymanager/tests/test_keymanager.py b/keymanager/src/leap/keymanager/tests/test_keymanager.py
index c55a3c3..3572fb2 100644
--- a/keymanager/src/leap/keymanager/tests/test_keymanager.py
+++ b/keymanager/src/leap/keymanager/tests/test_keymanager.py
@@ -92,7 +92,7 @@ class KeyManagerUtilTestCase(unittest.TestCase):
'encr_used': False,
'sign_used': True,
}
- key = build_key_from_dict(OpenPGPKey, kdict, adict)
+ key = build_key_from_dict(kdict, adict)
self.assertEqual(
kdict['uids'], key.uids,
'Wrong data in key.')