summaryrefslogtreecommitdiff
path: root/keymanager
diff options
context:
space:
mode:
authorRuben Pollan <meskio@sindominio.net>2016-05-01 15:38:45 -0300
committerRuben Pollan <meskio@sindominio.net>2016-06-01 18:49:15 +0200
commitbc027b0b0f051b81ebb3339653e8bbaeee875765 (patch)
tree0384bdd6c543123ed92710e039cae17d4da6541f /keymanager
parentea0dfc4f873c2a23800b92bc83a952160ce9decc (diff)
[feat] remove keytype from build_key_from_dict
Diffstat (limited to 'keymanager')
-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 f72f4036..32e55818 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 1d039451..296ed865 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 f8cc9765..fae56005 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 c55a3c38..3572fb28 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.')