Add some test code to dump contents of the cache

This commit is contained in:
Olivier Berger 2013-11-15 14:34:23 +01:00
parent 8ebe8bfede
commit d12111b400
1 changed files with 23 additions and 0 deletions

View File

@ -26,6 +26,7 @@ given keyring.
"""
import logging
import time
import sys
db = None
cachetimestamp = 0
@ -84,3 +85,25 @@ def getLoginByFingerprint(fpr):
Gets the login associated with the given fingerprint if available.
"""
return _get_cached('login:fpr:%s' % fpr)
def _dump_cache():
cache = _get_keyring_cache()
fprs = []
for key in cache.keys():
if key.startswith('email:fpr:'):
fpr = key.replace('email:fpr:', '')
if not fpr in fprs:
fprs.append(fpr)
for fpr in fprs:
login = getLoginByFingerprint(fpr)
email = _get_cached('email:fpr:%s' % fpr)
name = _get_cached('name:fpr:%s' % fpr)
print fpr, login, ':'
print ' ', name, email
if __name__ == '__main__':
logging.basicConfig(stream=sys.stderr, level=logging.WARNING)
_dump_cache()