summaryrefslogtreecommitdiff
path: root/src/leap/keymanager/keys.py
diff options
context:
space:
mode:
authorKali Kaneko (leap communications) <kali@leap.se>2016-05-04 17:50:06 -0400
committerKali Kaneko (leap communications) <kali@leap.se>2016-05-04 17:50:06 -0400
commit52e4303cf2e0f8a51df33d3f8f30310ca5897069 (patch)
treebafd16759f62a080177f0edfcf8be449ebfc9000 /src/leap/keymanager/keys.py
parente20490628bfd714fd90a8e92f1d8c91c21f67830 (diff)
parent0aecef293fd86507da3565219982ce31c5cfde06 (diff)
Merge branch 'develop' into release/0.5.10.5.1
Diffstat (limited to 'src/leap/keymanager/keys.py')
-rw-r--r--src/leap/keymanager/keys.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/leap/keymanager/keys.py b/src/leap/keymanager/keys.py
index 38d66b5f..1955d545 100644
--- a/src/leap/keymanager/keys.py
+++ b/src/leap/keymanager/keys.py
@@ -192,6 +192,11 @@ class EncryptionKey(object):
__metaclass__ = ABCMeta
+ __slots__ = ('address', 'uids', 'fingerprint', 'key_data',
+ 'private', 'length', 'expiry_date', 'validation',
+ 'last_audited_at', 'refreshed_at',
+ 'encr_used', 'sign_used', '_index')
+
def __init__(self, address=None, uids=[], fingerprint="",
key_data="", private=False, length=0, expiry_date=None,
validation=ValidationLevels.Weak_Chain, last_audited_at=None,
@@ -212,6 +217,7 @@ class EncryptionKey(object):
self.refreshed_at = refreshed_at
self.encr_used = encr_used
self.sign_used = sign_used
+ self._index = len(self.__slots__)
def get_json(self):
"""
@@ -258,6 +264,27 @@ class EncryptionKey(object):
KEY_TAGS_KEY: [KEYMANAGER_ACTIVE_TAG],
})
+ def next(self):
+ if self._index == 0:
+ self._index = len(self.__slots__)
+ raise StopIteration
+
+ self._index -= 1
+ key = self.__slots__[self._index]
+
+ if key.startswith('_'):
+ return self.next()
+
+ value = getattr(self, key)
+ if key == "validation":
+ value = str(value)
+ elif key in ["expiry_date", "last_audited_at", "refreshed_at"]:
+ value = str(value)
+ return key, value
+
+ def __iter__(self):
+ return self
+
def __repr__(self):
"""
Representation of this class