aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPavlos Ratis <dastergon@dastergon.gr>2014-11-29 17:38:49 +0200
committerPavlos Ratis <dastergon@dastergon.gr>2014-11-29 17:38:49 +0200
commitd2915cff1be3162010e019a25be3b609cf53d29a (patch)
treee8fccae8bb19df7c51d96dea39bebbc0c6110dad
parentupdate spec file urls to api.g.o (diff)
parentgkeys/actions.py: Add -i, --keyid option to listkey and checkkey (diff)
downloadgentoo-keys-d2915cff1be3162010e019a25be3b609cf53d29a.tar.gz
gentoo-keys-d2915cff1be3162010e019a25be3b609cf53d29a.tar.bz2
gentoo-keys-d2915cff1be3162010e019a25be3b609cf53d29a.zip
Merge pull request #33 from gentoo/dol-sen-PR
Add -i, --keyid option
-rw-r--r--gkeys/actions.py4
-rw-r--r--gkeys/cli.py6
-rw-r--r--gkeys/seed.py13
-rw-r--r--gkeys/seedhandler.py2
4 files changed, 21 insertions, 4 deletions
diff --git a/gkeys/actions.py b/gkeys/actions.py
index 1f9621b..dc36f7c 100644
--- a/gkeys/actions.py
+++ b/gkeys/actions.py
@@ -34,14 +34,14 @@ Action_Options = {
'moveseed': ['nick', 'name', 'keydir', 'fingerprint', 'seedfile', 'dest'],
'fetchseed': ['nick', 'name', 'keydir', 'fingerprint', 'seedfile'],
'listseedfiles': [],
- 'listkey': ['nick', 'name', 'keydir', 'fingerprint', 'category', 'keyring', 'gpgsearch'],
+ 'listkey': ['nick', 'name', 'keydir', 'fingerprint', 'category', 'keyring', 'gpgsearch', 'keyid'],
'installkey': ['nick', 'name', 'keydir', 'fingerprint', 'category', 'keyring', 'seedfile'],
'removekey': ['nick', 'name', 'keydir', 'fingerprint', 'category', 'keyring'],
'movekey': ['nick', 'name', 'keydir', 'fingerprint', 'category', 'keyring', 'dest'],
'installed': ['nick', 'name', 'keydir', 'fingerprint', 'category', 'keyring'],
'importkey': ['nick', 'name', 'keydir', 'fingerprint', 'category', 'keyring'],
'verify': ['dest', 'nick', 'name', 'keydir', 'fingerprint', 'category', 'file', 'signature', 'keyring', 'timestamp'],
- 'checkkey': ['nick', 'name', 'keydir', 'fingerprint', 'category', 'keyring'],
+ 'checkkey': ['nick', 'name', 'keydir', 'fingerprint', 'category', 'keyring', 'keyid'],
'sign': ['nick', 'name', 'keydir', 'fingerprint', 'file', 'keyring'],
}
diff --git a/gkeys/cli.py b/gkeys/cli.py
index ade3a4d..4c1e946 100644
--- a/gkeys/cli.py
+++ b/gkeys/cli.py
@@ -68,6 +68,12 @@ class Main(object):
help='Do a gpg search operations, rather than a gkey search')
@staticmethod
+ def _option_keyid(parser=None):
+ parser.add_argument('-i', '--keyid', dest='keyid', default=None,
+ nargs='+',
+ help='The long keyid of the gpg key to search for')
+
+ @staticmethod
def _option_keyring(parser=None):
parser.add_argument('-k', '--keyring', dest='keyring', default='trusted_keyring',
help='The name of the keyring to use')
diff --git a/gkeys/seed.py b/gkeys/seed.py
index c68ee9f..f0cb019 100644
--- a/gkeys/seed.py
+++ b/gkeys/seed.py
@@ -127,9 +127,20 @@ class Seeds(object):
keys = kwargs
result = self.seeds
for key in keys:
- if key in ['fingerprint']:
+ if key in ['fingerprint', 'keyid']:
kwargs[key] = [x.replace(' ', '').upper() for x in kwargs[key]]
+ if key in ['fingerprint']:
result = {dev: gkey for dev, gkey in list(result.items()) if kwargs[key][0] in getattr(gkey, key)}
+ elif key in ['keyid']:
+ searchids = [x.lstrip('0X') for x in kwargs[key]]
+ res = {}
+ for dev, gkey in list(result.items()):
+ keyids = [x.lstrip("0x") for x in getattr(gkey, key)]
+ for keyid in searchids:
+ if keyid in keyids:
+ res[dev] = gkey
+ break
+ result = res
else:
result = {dev: gkey for dev, gkey in list(result.items()) if kwargs[key].lower() in getattr(gkey, key).lower()}
return sorted(result.values())
diff --git a/gkeys/seedhandler.py b/gkeys/seedhandler.py
index 6a9c2e8..8e06fab 100644
--- a/gkeys/seedhandler.py
+++ b/gkeys/seedhandler.py
@@ -46,7 +46,7 @@ class SeedHandler(object):
@staticmethod
def build_gkeydict(args):
keyinfo = {}
- for attr in GKEY._fields:
+ for attr in GKEY._fields + ('keyid',):
try:
value = getattr(args, attr)
if attr == 'name' and value: