python: hkp key importer

* Tweaked it slightly to avoid repetition of key searches when there
  is only one search pattern to check (i.e. usually a single key ID or
  fingerprint).
This commit is contained in:
Ben McGinnes 2018-12-11 09:55:15 +11:00
parent 2e7a14c9b3
commit 772b5aae24

View File

@ -58,32 +58,37 @@ if pattern is not None:
if keyed is True:
try:
fob = server.search(pattern)
except:
except Exception as e:
fob = None
if fob is not None:
keys.append(fob[0])
else:
pass
else:
pass
else:
pass
for logrus in pattern.split():
try:
key = server.search(hex(int(logrus, 16)))
hexed = True
except ValueError as ve:
key = server.search(logrus)
hexed = False
if logrus != pattern:
try:
key = server.search(hex(int(logrus, 16)))
hexed = True
except ValueError as ve:
key = server.search(logrus)
hexed = False
if key is not None:
keys.append(key[0])
if hexed is True:
try:
fob = server.search(logrus)
except:
fob = None
if fob is not None:
keys.append(fob[0])
if key is not None:
keys.append(key[0])
if hexed is True:
try:
fob = server.search(logrus)
except Exception as e:
fob = None
if fob is not None:
keys.append(fob[0])
else:
pass
else:
pass
else:
pass
else: