From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <gentoo-commits+bounces-761069-garchives=archives.gentoo.org@lists.gentoo.org>
Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80])
	by finch.gentoo.org (Postfix) with ESMTP id 157A71389E2
	for <garchives@archives.gentoo.org>; Wed, 31 Dec 2014 21:34:36 +0000 (UTC)
Received: from pigeon.gentoo.org (localhost [127.0.0.1])
	by pigeon.gentoo.org (Postfix) with SMTP id 6A903E08BD;
	Wed, 31 Dec 2014 21:34:34 +0000 (UTC)
Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183])
	(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by pigeon.gentoo.org (Postfix) with ESMTPS id 50851E08BB
	for <gentoo-commits@lists.gentoo.org>; Wed, 31 Dec 2014 21:34:33 +0000 (UTC)
Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52])
	(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by smtp.gentoo.org (Postfix) with ESMTPS id 3B9C93406D6
	for <gentoo-commits@lists.gentoo.org>; Wed, 31 Dec 2014 21:34:32 +0000 (UTC)
Received: from localhost.localdomain (localhost [127.0.0.1])
	by oystercatcher.gentoo.org (Postfix) with ESMTP id DD9BAE97D
	for <gentoo-commits@lists.gentoo.org>; Wed, 31 Dec 2014 21:34:30 +0000 (UTC)
From: "Brian Dolbec" <dolsen@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Content-Transfer-Encoding: 8bit
Content-type: text/plain; charset=UTF-8
Reply-To: gentoo-dev@lists.gentoo.org, "Brian Dolbec" <dolsen@gentoo.org>
Message-ID: <1419975746.5d9e409c8e2dbd6c93052f848b02740bf8dc58c2.dolsen@gentoo.org@gentoo>
Subject: [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
X-VCS-Repository: proj/gentoo-keys
X-VCS-Files: gkeys/gkeys/gkey.py
X-VCS-Directories: gkeys/gkeys/
X-VCS-Committer: dolsen@gentoo.org
X-VCS-Committer-Name: Brian Dolbec
X-VCS-Revision: 5d9e409c8e2dbd6c93052f848b02740bf8dc58c2
X-VCS-Branch: master
Date: Wed, 31 Dec 2014 21:34:30 +0000 (UTC)
Precedence: bulk
List-Post: <mailto:gentoo-commits@lists.gentoo.org>
List-Help: <mailto:gentoo-commits+help@lists.gentoo.org>
List-Unsubscribe: <mailto:gentoo-commits+unsubscribe@lists.gentoo.org>
List-Subscribe: <mailto:gentoo-commits+subscribe@lists.gentoo.org>
List-Id: Gentoo Linux mail <gentoo-commits.gentoo.org>
X-BeenThere: gentoo-commits@lists.gentoo.org
X-Archives-Salt: a0a5667f-b0de-46c4-9906-d8512b9cab33
X-Archives-Hash: 278f23444cceb53455427dc7a5c0ff89

commit:     5d9e409c8e2dbd6c93052f848b02740bf8dc58c2
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sat Dec 27 21:37:23 2014 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Tue Dec 30 21:42:26 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=5d9e409c

gkeys/gkey.py: Add keys and uid fields, update() to GKEY

keys field will hold the primary key fingerprints for the (to be/) installed GKEY.
fingerprints and uid fileds will be populated with all uid's and fingerprints defined in subkeys using the update().

---
 gkeys/gkeys/gkey.py | 32 +++++++++++++++++++++++++++++---
 1 file changed, 29 insertions(+), 3 deletions(-)

diff --git a/gkeys/gkeys/gkey.py b/gkeys/gkeys/gkey.py
index 41c6d8b..463f007 100644
--- a/gkeys/gkeys/gkey.py
+++ b/gkeys/gkeys/gkey.py
@@ -18,6 +18,7 @@ GKEY_STRING = '''    ----------
     Name.........: %(name)s
     Nick.........: %(nick)s
     Keydir.......: %(keydir)s
+    UID..........: %(uid)s
 '''
 
 GKEY_FINGERPRINTS = \
@@ -26,10 +27,11 @@ GKEY_FINGERPRINTS = \
 '''
 
 
-class GKEY(namedtuple('GKEY', ['nick', 'name', 'keydir', 'fingerprint'])):
+class GKEY(namedtuple('GKEY', ['nick', 'name', 'keydir', 'keys', 'fingerprint', 'uid'])):
     '''Class to hold the relavent info about a key'''
 
-    field_types = {'nick': str, 'name': str, 'keydir': str, 'fingerprint': list}
+    field_types = {'nick': str, 'name': str, 'keydir': str, 'keys': list,
+        'fingerprint': list, 'uid': list}
     __slots__ = ()
 
 
@@ -42,7 +44,12 @@ class GKEY(namedtuple('GKEY', ['nick', 'name', 'keydir', 'fingerprint'])):
     @property
     def pretty_print(self):
         '''Pretty printing a GKEY'''
-        gkey = {'name': self.name, 'nick': self.nick, 'keydir': self.keydir}
+        gkey = {
+            'name': self.name,
+            'nick': self.nick,
+            'keydir': self.keydir,
+            'uid': self.uid,
+            }
         output = GKEY_STRING % gkey
         for f in self.fingerprint:
             fingerprint = {'fingerprint': f, 'keyid': '0x' + f[-16:]}
@@ -50,6 +57,25 @@ class GKEY(namedtuple('GKEY', ['nick', 'name', 'keydir', 'fingerprint'])):
         return output
 
 
+    def update(self, result_list):
+        '''Processes a results instance from a colon listing
+        and mines all fingerprints found.
+
+        @param result_list: list of pyGPG.output.GPGResult instances
+            (one for each fingerprint in the list)
+        @return: A new, updated GKEY instance
+        '''
+        fingerprints = set()
+        uids = set()
+        for result in result_list:
+            for data in result.status.data:
+                if data.name ==  "FPR":
+                    fingerprints.add(data.fingerprint)
+                elif data.name ==  "UID":
+                    uids.add(data.user_ID)
+        return self._make([self.nick, self.name, self.keydir, self.keys, list(fingerprints), sorted(uids)])
+
+
 class GKEY_CHECK(namedtuple('GKEY_CHECK', ['keyid', 'revoked', 'expired', 'invalid', 'sign'])):
 
     __slots__ = ()