Gentoo Archives: gentoo-commits

From: Brian Dolbec <dolsen@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
Date: Wed, 31 Dec 2014 21:34:35
Message-Id: 1419975746.ffb2d93b1085c600cee9bd6fa2cf17c098c3bc2c.dolsen@gentoo.org@gentoo
1 commit: ffb2d93b1085c600cee9bd6fa2cf17c098c3bc2c
2 Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
3 AuthorDate: Sat Dec 27 21:33:07 2014 +0000
4 Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
5 CommitDate: Tue Dec 30 21:42:26 2014 +0000
6 URL: http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=ffb2d93b
7
8 gkeys: Move all GKEYS definitions to it's own file
9
10 Fix imports in other files.
11
12 ---
13 gkeys/gkeys/actions.py | 2 +-
14 gkeys/gkeys/checks.py | 2 +-
15 gkeys/gkeys/config.py | 41 +---------------------------------
16 gkeys/gkeys/gkey.py | 55 ++++++++++++++++++++++++++++++++++++++++++++++
17 gkeys/gkeys/seed.py | 2 +-
18 gkeys/gkeys/seedhandler.py | 2 +-
19 6 files changed, 60 insertions(+), 44 deletions(-)
20
21 diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py
22 index be1823f..9baecaa 100644
23 --- a/gkeys/gkeys/actions.py
24 +++ b/gkeys/gkeys/actions.py
25 @@ -27,7 +27,7 @@ from shutil import rmtree
26
27 from gkeys.lib import GkeysGPG
28 from gkeys.seedhandler import SeedHandler
29 -from gkeys.config import GKEY
30 +from gkeys.gkey import GKEY
31 from gkeys.checks import SPECCHECK_SUMMARY, convert_pf, convert_yn
32
33
34
35 diff --git a/gkeys/gkeys/checks.py b/gkeys/gkeys/checks.py
36 index 69df9c4..bddad5f 100644
37 --- a/gkeys/gkeys/checks.py
38 +++ b/gkeys/gkeys/checks.py
39 @@ -12,7 +12,7 @@
40 import time
41 from collections import namedtuple, OrderedDict
42
43 -from gkeys.config import GKEY_CHECK
44 +from gkeys.gkey import GKEY_CHECK
45
46 from pyGPG.mappings import (ALGORITHM_CODES, CAPABILITY_MAP,
47 KEY_VERSION_FPR_LEN, VALIDITY_MAP, VALID_LIST)
48
49 diff --git a/gkeys/gkeys/config.py b/gkeys/gkeys/config.py
50 index 6eba2b3..8fa4c1b 100644
51 --- a/gkeys/gkeys/config.py
52 +++ b/gkeys/gkeys/config.py
53 @@ -6,14 +6,13 @@
54
55 Holds configuration keys and values
56
57 - @copyright: 2012 by Brian Dolbec <dol-sen@g.o>
58 + @copyright: 2012-2015 by Brian Dolbec <dol-sen@g.o>
59 @license: GNU GNU GPL2, see COPYING for details.
60 """
61
62 import os
63
64 from collections import OrderedDict
65 -from collections import namedtuple
66
67 from pyGPG.config import GPGConfig
68
69 @@ -30,16 +29,6 @@ EPREFIX = "@GENTOO_PORTAGE_EPREFIX@"
70 if "GENTOO_PORTAGE_EPREFIX" in EPREFIX:
71 EPREFIX = ''
72
73 -GKEY_STRING = ''' ----------
74 - Name.........: %(name)s
75 - Nick.........: %(nick)s
76 - Keydir.......: %(keydir)s
77 -'''
78 -
79 -GKEY_FINGERPRINTS = \
80 -''' Keyid........: %(keyid)s
81 - Fingerprint: %(fingerprint)s
82 -'''
83
84 MAPSEEDS = { 'dev' : 'gentoodevs.seeds', 'rel': 'gentoo.seeds' }
85
86 @@ -137,31 +126,3 @@ class GKeysConfig(GPGConfig):
87 else:
88 return super(GKeysConfig, self)._get_(key, subkey)
89
90 -
91 -class GKEY(namedtuple('GKEY', ['nick', 'name', 'keydir', 'fingerprint'])):
92 - '''Class to hold the relavent info about a key'''
93 -
94 - field_types = {'nick': str, 'name': str, 'keydir': str, 'fingerprint': list}
95 - __slots__ = ()
96 -
97 -
98 - @property
99 - def keyid(self):
100 - '''Keyid is a substring value of the fingerprint'''
101 - return ['0x' + x[-16:] for x in self.fingerprint]
102 -
103 -
104 - @property
105 - def pretty_print(self):
106 - '''Pretty printing a GKEY'''
107 - gkey = {'name': self.name, 'nick': self.nick, 'keydir': self.keydir}
108 - output = GKEY_STRING % gkey
109 - for f in self.fingerprint:
110 - fingerprint = {'fingerprint': f, 'keyid': '0x' + f[-16:]}
111 - output += GKEY_FINGERPRINTS % fingerprint
112 - return output
113 -
114 -
115 -class GKEY_CHECK(namedtuple('GKEY_CHECK', ['keyid', 'revoked', 'expired', 'invalid', 'sign'])):
116 -
117 - __slots__ = ()
118
119 diff --git a/gkeys/gkeys/gkey.py b/gkeys/gkeys/gkey.py
120 new file mode 100644
121 index 0000000..41c6d8b
122 --- /dev/null
123 +++ b/gkeys/gkeys/gkey.py
124 @@ -0,0 +1,55 @@
125 +#
126 +#-*- coding:utf-8 -*-
127 +
128 +"""
129 + Gentoo-keys - gkey.py
130 +
131 + Holds GKEY class and related values
132 +
133 + @copyright: 2012-2015 by Brian Dolbec <dol-sen@g.o>
134 + @license: GNU GNU GPL2, see COPYING for details.
135 +"""
136 +
137 +
138 +from collections import namedtuple
139 +
140 +
141 +GKEY_STRING = ''' ----------
142 + Name.........: %(name)s
143 + Nick.........: %(nick)s
144 + Keydir.......: %(keydir)s
145 +'''
146 +
147 +GKEY_FINGERPRINTS = \
148 +''' Keyid........: %(keyid)s
149 + Fingerprint: %(fingerprint)s
150 +'''
151 +
152 +
153 +class GKEY(namedtuple('GKEY', ['nick', 'name', 'keydir', 'fingerprint'])):
154 + '''Class to hold the relavent info about a key'''
155 +
156 + field_types = {'nick': str, 'name': str, 'keydir': str, 'fingerprint': list}
157 + __slots__ = ()
158 +
159 +
160 + @property
161 + def keyid(self):
162 + '''Keyid is a substring value of the fingerprint'''
163 + return ['0x' + x[-16:] for x in self.fingerprint]
164 +
165 +
166 + @property
167 + def pretty_print(self):
168 + '''Pretty printing a GKEY'''
169 + gkey = {'name': self.name, 'nick': self.nick, 'keydir': self.keydir}
170 + output = GKEY_STRING % gkey
171 + for f in self.fingerprint:
172 + fingerprint = {'fingerprint': f, 'keyid': '0x' + f[-16:]}
173 + output += GKEY_FINGERPRINTS % fingerprint
174 + return output
175 +
176 +
177 +class GKEY_CHECK(namedtuple('GKEY_CHECK', ['keyid', 'revoked', 'expired', 'invalid', 'sign'])):
178 +
179 + __slots__ = ()
180
181 diff --git a/gkeys/gkeys/seed.py b/gkeys/gkeys/seed.py
182 index 2406c1a..16fe0fd 100644
183 --- a/gkeys/gkeys/seed.py
184 +++ b/gkeys/gkeys/seed.py
185 @@ -20,7 +20,7 @@ import json
186 import os
187
188 from gkeys.log import logger
189 -from gkeys.config import GKEY
190 +from gkeys.gkey import GKEY
191 from gkeys.fileops import ensure_dirs
192
193
194
195 diff --git a/gkeys/gkeys/seedhandler.py b/gkeys/gkeys/seedhandler.py
196 index 2222bd2..33ed787 100644
197 --- a/gkeys/gkeys/seedhandler.py
198 +++ b/gkeys/gkeys/seedhandler.py
199 @@ -14,7 +14,7 @@ import os
200 import re
201 from json import load
202
203 -from gkeys.config import GKEY
204 +from gkeys.gkey import GKEY
205 from gkeys.seed import Seeds
206 from gkeys.fileops import ensure_dirs