Gentoo Archives: gentoo-commits

From: Brian Dolbec <brian.dolbec@×××××.com>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/
Date: Sun, 01 Jun 2014 15:25:46
Message-Id: 1401636096.18e4734f2181d8152e37cfbb1f2903ba6ce52f91.dol-sen@gentoo
1 commit: 18e4734f2181d8152e37cfbb1f2903ba6ce52f91
2 Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
3 AuthorDate: Sun Jun 1 15:15:35 2014 +0000
4 Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
5 CommitDate: Sun Jun 1 15:21:36 2014 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=18e4734f
7
8 GKEY: New pretty_print property
9
10 Update cli.output_results to use the new property.
11
12 ---
13 gkeys/cli.py | 2 +-
14 gkeys/config.py | 21 +++++++++++++++++++++
15 2 files changed, 22 insertions(+), 1 deletion(-)
16
17 diff --git a/gkeys/cli.py b/gkeys/cli.py
18 index 200ca87..dd1b45a 100644
19 --- a/gkeys/cli.py
20 +++ b/gkeys/cli.py
21 @@ -147,7 +147,7 @@ class Main(object):
22 def output_results(results, header):
23 # super simple output for the time being
24 print(header)
25 - print("\n".join([str(x) for x in results]))
26 + print("\n".join([x.pretty_print for x in results]))
27 print()
28
29
30
31 diff --git a/gkeys/config.py b/gkeys/config.py
32 index 161315e..e9537b0 100644
33 --- a/gkeys/config.py
34 +++ b/gkeys/config.py
35 @@ -40,6 +40,15 @@ if "GENTOO_PORTAGE_EPREFIX" in EPREFIX:
36
37 SEED_TYPES = ['dev', 'release']
38
39 +GKEY_STRING = ''' ----------
40 + Name.........: %(name)s
41 + Nick.........: %(nick)s
42 + Keydir.......: %(keydir)s
43 +'''
44 +GKEY_FINGERPRINTS = \
45 +''' Keyid........: %(keyid)s
46 + Fingerprint: %(fingerprint)s
47 +'''
48
49 class GKeysConfig(GPGConfig):
50 """ Configuration superclass which holds our gentoo-keys
51 @@ -126,3 +135,15 @@ class GKEY(namedtuple('GKEY', ['nick', 'name', 'keydir', 'fingerprint'])):
52 def keyid(self):
53 '''Keyid is a substring value of the fingerprint'''
54 return ['0x' + x[-16:] for x in self.fingerprint]
55 +
56 +
57 + @property
58 + def pretty_print(self):
59 + '''Pretty printing a GKEY'''
60 + gkey = {'name': ', '.join(self.name), 'nick': ', '.join(self.nick)
61 + , 'keydir': ', '.join(self.keydir)}
62 + output = GKEY_STRING % gkey
63 + for f in self.fingerprint:
64 + fingerprint = {'fingerprint': f, 'keyid': '0x' + f[-16:]}
65 + output += GKEY_FINGERPRINTS % fingerprint
66 + return output