aboutsummaryrefslogtreecommitdiff
path: root/gkeys
diff options
context:
space:
mode:
authorBrian Dolbec <dolsen@gentoo.org>2014-12-27 13:33:07 -0800
committerBrian Dolbec <dolsen@gentoo.org>2014-12-30 13:42:26 -0800
commitffb2d93b1085c600cee9bd6fa2cf17c098c3bc2c (patch)
treeb3dd183fbc150c5d97b77a11bbf14b5ae67ca494 /gkeys
parentgkeys: Add key-search action (diff)
downloadgentoo-keys-ffb2d93b1085c600cee9bd6fa2cf17c098c3bc2c.tar.gz
gentoo-keys-ffb2d93b1085c600cee9bd6fa2cf17c098c3bc2c.tar.bz2
gentoo-keys-ffb2d93b1085c600cee9bd6fa2cf17c098c3bc2c.zip
gkeys: Move all GKEYS definitions to it's own file
Fix imports in other files.
Diffstat (limited to 'gkeys')
-rw-r--r--gkeys/gkeys/actions.py2
-rw-r--r--gkeys/gkeys/checks.py2
-rw-r--r--gkeys/gkeys/config.py41
-rw-r--r--gkeys/gkeys/gkey.py55
-rw-r--r--gkeys/gkeys/seed.py2
-rw-r--r--gkeys/gkeys/seedhandler.py2
6 files changed, 60 insertions, 44 deletions
diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py
index be1823f..9baecaa 100644
--- a/gkeys/gkeys/actions.py
+++ b/gkeys/gkeys/actions.py
@@ -27,7 +27,7 @@ from shutil import rmtree
from gkeys.lib import GkeysGPG
from gkeys.seedhandler import SeedHandler
-from gkeys.config import GKEY
+from gkeys.gkey import GKEY
from gkeys.checks import SPECCHECK_SUMMARY, convert_pf, convert_yn
diff --git a/gkeys/gkeys/checks.py b/gkeys/gkeys/checks.py
index 69df9c4..bddad5f 100644
--- a/gkeys/gkeys/checks.py
+++ b/gkeys/gkeys/checks.py
@@ -12,7 +12,7 @@
import time
from collections import namedtuple, OrderedDict
-from gkeys.config import GKEY_CHECK
+from gkeys.gkey import GKEY_CHECK
from pyGPG.mappings import (ALGORITHM_CODES, CAPABILITY_MAP,
KEY_VERSION_FPR_LEN, VALIDITY_MAP, VALID_LIST)
diff --git a/gkeys/gkeys/config.py b/gkeys/gkeys/config.py
index 6eba2b3..8fa4c1b 100644
--- a/gkeys/gkeys/config.py
+++ b/gkeys/gkeys/config.py
@@ -6,14 +6,13 @@
Holds configuration keys and values
- @copyright: 2012 by Brian Dolbec <dol-sen@gentoo.org>
+ @copyright: 2012-2015 by Brian Dolbec <dol-sen@gentoo.org>
@license: GNU GNU GPL2, see COPYING for details.
"""
import os
from collections import OrderedDict
-from collections import namedtuple
from pyGPG.config import GPGConfig
@@ -30,16 +29,6 @@ EPREFIX = "@GENTOO_PORTAGE_EPREFIX@"
if "GENTOO_PORTAGE_EPREFIX" in EPREFIX:
EPREFIX = ''
-GKEY_STRING = ''' ----------
- Name.........: %(name)s
- Nick.........: %(nick)s
- Keydir.......: %(keydir)s
-'''
-
-GKEY_FINGERPRINTS = \
-''' Keyid........: %(keyid)s
- Fingerprint: %(fingerprint)s
-'''
MAPSEEDS = { 'dev' : 'gentoodevs.seeds', 'rel': 'gentoo.seeds' }
@@ -137,31 +126,3 @@ class GKeysConfig(GPGConfig):
else:
return super(GKeysConfig, self)._get_(key, subkey)
-
-class GKEY(namedtuple('GKEY', ['nick', 'name', 'keydir', 'fingerprint'])):
- '''Class to hold the relavent info about a key'''
-
- field_types = {'nick': str, 'name': str, 'keydir': str, 'fingerprint': list}
- __slots__ = ()
-
-
- @property
- def keyid(self):
- '''Keyid is a substring value of the fingerprint'''
- return ['0x' + x[-16:] for x in self.fingerprint]
-
-
- @property
- def pretty_print(self):
- '''Pretty printing a GKEY'''
- gkey = {'name': self.name, 'nick': self.nick, 'keydir': self.keydir}
- output = GKEY_STRING % gkey
- for f in self.fingerprint:
- fingerprint = {'fingerprint': f, 'keyid': '0x' + f[-16:]}
- output += GKEY_FINGERPRINTS % fingerprint
- return output
-
-
-class GKEY_CHECK(namedtuple('GKEY_CHECK', ['keyid', 'revoked', 'expired', 'invalid', 'sign'])):
-
- __slots__ = ()
diff --git a/gkeys/gkeys/gkey.py b/gkeys/gkeys/gkey.py
new file mode 100644
index 0000000..41c6d8b
--- /dev/null
+++ b/gkeys/gkeys/gkey.py
@@ -0,0 +1,55 @@
+#
+#-*- coding:utf-8 -*-
+
+"""
+ Gentoo-keys - gkey.py
+
+ Holds GKEY class and related values
+
+ @copyright: 2012-2015 by Brian Dolbec <dol-sen@gentoo.org>
+ @license: GNU GNU GPL2, see COPYING for details.
+"""
+
+
+from collections import namedtuple
+
+
+GKEY_STRING = ''' ----------
+ Name.........: %(name)s
+ Nick.........: %(nick)s
+ Keydir.......: %(keydir)s
+'''
+
+GKEY_FINGERPRINTS = \
+''' Keyid........: %(keyid)s
+ Fingerprint: %(fingerprint)s
+'''
+
+
+class GKEY(namedtuple('GKEY', ['nick', 'name', 'keydir', 'fingerprint'])):
+ '''Class to hold the relavent info about a key'''
+
+ field_types = {'nick': str, 'name': str, 'keydir': str, 'fingerprint': list}
+ __slots__ = ()
+
+
+ @property
+ def keyid(self):
+ '''Keyid is a substring value of the fingerprint'''
+ return ['0x' + x[-16:] for x in self.fingerprint]
+
+
+ @property
+ def pretty_print(self):
+ '''Pretty printing a GKEY'''
+ gkey = {'name': self.name, 'nick': self.nick, 'keydir': self.keydir}
+ output = GKEY_STRING % gkey
+ for f in self.fingerprint:
+ fingerprint = {'fingerprint': f, 'keyid': '0x' + f[-16:]}
+ output += GKEY_FINGERPRINTS % fingerprint
+ return output
+
+
+class GKEY_CHECK(namedtuple('GKEY_CHECK', ['keyid', 'revoked', 'expired', 'invalid', 'sign'])):
+
+ __slots__ = ()
diff --git a/gkeys/gkeys/seed.py b/gkeys/gkeys/seed.py
index 2406c1a..16fe0fd 100644
--- a/gkeys/gkeys/seed.py
+++ b/gkeys/gkeys/seed.py
@@ -20,7 +20,7 @@ import json
import os
from gkeys.log import logger
-from gkeys.config import GKEY
+from gkeys.gkey import GKEY
from gkeys.fileops import ensure_dirs
diff --git a/gkeys/gkeys/seedhandler.py b/gkeys/gkeys/seedhandler.py
index 2222bd2..33ed787 100644
--- a/gkeys/gkeys/seedhandler.py
+++ b/gkeys/gkeys/seedhandler.py
@@ -14,7 +14,7 @@ import os
import re
from json import load
-from gkeys.config import GKEY
+from gkeys.gkey import GKEY
from gkeys.seed import Seeds
from gkeys.fileops import ensure_dirs