From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 498081389E2 for ; Wed, 31 Dec 2014 21:34:35 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 1ECBFE08B8; 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 4F57CE08BA for ; 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 2AC8C3406CA for ; 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 CDB80E97C for ; Wed, 31 Dec 2014 21:34:30 +0000 (UTC) From: "Brian Dolbec" 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" Message-ID: <1419975746.ffb2d93b1085c600cee9bd6fa2cf17c098c3bc2c.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/actions.py gkeys/gkeys/checks.py gkeys/gkeys/config.py gkeys/gkeys/gkey.py gkeys/gkeys/seed.py gkeys/gkeys/seedhandler.py X-VCS-Directories: gkeys/gkeys/ X-VCS-Committer: dolsen@gentoo.org X-VCS-Committer-Name: Brian Dolbec X-VCS-Revision: ffb2d93b1085c600cee9bd6fa2cf17c098c3bc2c X-VCS-Branch: master Date: Wed, 31 Dec 2014 21:34:30 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: 25130ec9-698d-402b-9051-ac7c8ebc83fd X-Archives-Hash: 6c155d7cf43aceb13c65de42230eccba commit: ffb2d93b1085c600cee9bd6fa2cf17c098c3bc2c Author: Brian Dolbec gentoo org> AuthorDate: Sat Dec 27 21:33:07 2014 +0000 Commit: Brian Dolbec gentoo org> CommitDate: Tue Dec 30 21:42:26 2014 +0000 URL: http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=ffb2d93b gkeys: Move all GKEYS definitions to it's own file Fix imports in other files. --- gkeys/gkeys/actions.py | 2 +- gkeys/gkeys/checks.py | 2 +- gkeys/gkeys/config.py | 41 +--------------------------------- gkeys/gkeys/gkey.py | 55 ++++++++++++++++++++++++++++++++++++++++++++++ gkeys/gkeys/seed.py | 2 +- gkeys/gkeys/seedhandler.py | 2 +- 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 + @copyright: 2012-2015 by Brian Dolbec @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 + @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