From: "Brian Dolbec" <dolsen@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
Date: Sun, 9 Aug 2015 01:09:33 +0000 (UTC) [thread overview]
Message-ID: <1439049100.317de4981cc9208f5ff4595f048fb17f522283f6.dolsen@gentoo> (raw)
commit: 317de4981cc9208f5ff4595f048fb17f522283f6
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Wed Jul 29 06:18:41 2015 +0000
Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Sat Aug 8 15:51:40 2015 +0000
URL: https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=317de498
gkeys: [1 of 2] Creation of a new ActionBase class
This class is to hold non-action functions/methods
Restructure external handlers.
Creation of @property decorated keyhandler, seedhandler, gpg functions to
initialize and return.the classwide instances of their code.
gkeys/gkeys/actionbase.py | 90 +++++++++++++++++++++++++++++++++++++++++++++++
gkeys/gkeys/actions.py | 10 ++----
2 files changed, 93 insertions(+), 7 deletions(-)
diff --git a/gkeys/gkeys/actionbase.py b/gkeys/gkeys/actionbase.py
new file mode 100644
index 0000000..77748c5
--- /dev/null
+++ b/gkeys/gkeys/actionbase.py
@@ -0,0 +1,90 @@
+#
+#-*- coding:utf-8 -*-
+
+"""
+ Gentoo-keys - actionbase.py
+
+ Base api interface module
+
+ @copyright: 2012-2015 by Brian Dolbec <dol-sen@gentoo.org>
+ @license: GNU GPL2, see COPYING for details.
+"""
+
+from __future__ import print_function
+
+import os
+import sys
+
+if sys.version_info[0] >= 3:
+ _unicode = str
+else:
+ _unicode = unicode
+
+
+from snakeoil.demandload import demandload
+
+demandload(
+ "json:load",
+ "gkeys.lib:GkeysGPG",
+ "gkeys.keyhandler:KeyHandler",
+)
+
+
+
+class ActionBase(object):
+ '''Base actions class holding comon functions and init'''
+
+ def __init__(self, config, output=None, logger=None):
+ self.config = config
+ self.output = output
+ self.logger = logger
+ self.seeds = None
+ self._seedhandler = None
+ self._keyhandler = None
+ self._gpg = None
+ self.category = None
+
+
+ @property
+ def gpg(self):
+ '''Holds the classwide GkeysGPG instance'''
+ if not self._gpg:
+ self._gpg = GkeysGPG(self.config,
+ self._set_category(self.category), self.logger)
+ else:
+ self._gpg.basedir = self._set_category(self.category)
+ return self._gpg
+
+
+ @property
+ def keyhandler(self):
+ '''Holds the classwide KeyHandler instance'''
+ if not self._keyhandler:
+ self._init_keyhandler()
+ return self._keyhandler
+
+
+ def _init_keyhandler(self):
+ self._keyhandler = KeyHandler(self.config, self.logger)
+ self._seedhandler = self._keyhandler.seedhandler
+
+
+ @property
+ def seedhandler(self):
+ '''Holds the classwide SeedHandler instance
+ which is a convienience variable for the keyhandler's instance of it'''
+ if not self._seedhandler:
+ self._init_keyhandler()
+ return self._seedhandler
+
+
+ def _set_category(self, cat):
+ keyring = self.config.get_key('keyring')
+ if "foo-bar'd" in keyring:
+ raise
+ self.category = cat
+ catdir = os.path.join(keyring, cat)
+ self.logger.debug(_unicode("ACTIONS: _set_category; catdir = %s") % catdir)
+ return catdir
+
+
diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py
index e24d24d..11f1ca8 100644
--- a/gkeys/gkeys/actions.py
+++ b/gkeys/gkeys/actions.py
@@ -27,7 +27,7 @@ else:
from collections import defaultdict
from snakeoil.demandload import demandload
-
+from gkeys.actionbase import ActionBase
from gkeys.gkey import GKEY
from gkeys.checks import SPECCHECK_SUMMARY, convert_pf, convert_yn
@@ -41,14 +41,11 @@ demandload(
EXTENSIONS = ['.sig', '.asc', '.gpg','.gpgsig']
-class Actions(object):
+class Actions(ActionBase):
'''Primary API actions'''
def __init__(self, config, output=None, logger=None):
- self.config = config
- self.output = output
- self.logger = logger
- self.seeds = None
+ ActionBase.__init__(self, config, output, logger)
@staticmethod
@@ -68,7 +65,6 @@ class Actions(object):
'''-----< general actions >------'''
pass
-
def listseed(self, args):
'''Pretty-print the selected seed file'''
handler = SeedHandler(self.logger, self.config)
next reply other threads:[~2015-08-09 1:09 UTC|newest]
Thread overview: 144+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-09 1:09 Brian Dolbec [this message]
-- strict thread matches above, loose matches on Subject: below --
2018-08-15 16:15 [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/ Brian Dolbec
2018-08-15 1:51 Brian Dolbec
2018-08-15 1:05 Brian Dolbec
2018-07-07 15:10 Brian Dolbec
2018-07-07 15:10 Brian Dolbec
2018-07-07 5:23 Brian Dolbec
2018-07-07 5:23 Brian Dolbec
2018-07-07 5:23 Brian Dolbec
2018-07-07 5:23 Brian Dolbec
2018-07-07 5:23 Brian Dolbec
2018-07-07 5:23 Brian Dolbec
2018-07-07 5:23 Brian Dolbec
2018-07-07 5:23 Brian Dolbec
2018-07-07 5:23 Brian Dolbec
2018-07-07 5:23 Brian Dolbec
2018-07-07 5:23 Brian Dolbec
2018-07-07 5:23 Brian Dolbec
2018-07-07 5:23 Brian Dolbec
2018-07-07 5:23 Brian Dolbec
2018-07-07 5:23 Brian Dolbec
2018-07-07 5:23 Brian Dolbec
2018-07-07 5:23 Brian Dolbec
2018-07-07 5:23 Brian Dolbec
2016-12-24 9:13 [gentoo-commits] proj/gentoo-keys:gsoc-2016 " Brian Dolbec
2016-12-24 0:38 ` [gentoo-commits] proj/gentoo-keys:master " Brian Dolbec
2016-12-24 9:13 [gentoo-commits] proj/gentoo-keys:gsoc-2016 " Brian Dolbec
2016-10-27 21:49 ` [gentoo-commits] proj/gentoo-keys:master " Brian Dolbec
2016-12-24 9:13 [gentoo-commits] proj/gentoo-keys:gsoc-2016 " Brian Dolbec
2016-10-27 18:41 ` [gentoo-commits] proj/gentoo-keys:master " Brian Dolbec
2016-12-24 9:13 [gentoo-commits] proj/gentoo-keys:gsoc-2016 " Brian Dolbec
2016-12-24 0:38 ` [gentoo-commits] proj/gentoo-keys:master " Brian Dolbec
2016-12-24 4:52 Brian Dolbec
2016-06-01 15:16 Brian Dolbec
2016-06-01 15:16 Brian Dolbec
2016-01-23 23:33 Brian Dolbec
2016-01-23 23:33 Brian Dolbec
2016-01-23 19:04 Brian Dolbec
2015-12-25 17:03 Brian Dolbec
2015-12-13 0:51 Brian Dolbec
2015-08-25 14:10 Brian Dolbec
2015-08-25 14:10 Brian Dolbec
2015-08-09 22:52 Brian Dolbec
2015-08-09 1:09 Brian Dolbec
2015-08-09 1:09 Brian Dolbec
2015-08-09 1:09 Brian Dolbec
2015-08-09 1:09 Brian Dolbec
2015-08-09 1:09 Brian Dolbec
2015-08-09 1:09 Brian Dolbec
2015-08-09 1:09 Brian Dolbec
2015-08-09 1:09 Brian Dolbec
2015-08-09 1:09 Brian Dolbec
2015-08-09 1:09 Brian Dolbec
2015-07-25 16:45 Brian Dolbec
2015-07-25 16:45 Brian Dolbec
2015-07-25 16:45 Brian Dolbec
2015-06-22 13:41 Brian Dolbec
2015-06-01 1:56 Brian Dolbec
2015-05-31 5:03 Brian Dolbec
2015-05-31 5:03 Brian Dolbec
2015-05-31 5:03 Brian Dolbec
2015-05-31 5:03 Brian Dolbec
2015-05-31 5:03 Brian Dolbec
2015-05-31 5:03 Brian Dolbec
2015-05-31 5:03 Brian Dolbec
2015-05-31 5:03 Brian Dolbec
2015-05-31 5:03 Brian Dolbec
2015-05-31 5:03 Brian Dolbec
2015-05-31 5:03 Brian Dolbec
2015-05-31 5:03 Brian Dolbec
2015-05-31 5:03 Brian Dolbec
2015-05-31 5:03 Brian Dolbec
2015-05-31 5:03 Brian Dolbec
2015-05-31 5:03 Brian Dolbec
2015-05-31 5:03 Brian Dolbec
2015-03-18 15:32 Brian Dolbec
2015-03-17 19:51 Brian Dolbec
2015-03-08 15:09 Brian Dolbec
2015-03-06 21:04 Brian Dolbec
2015-02-11 17:37 Brian Dolbec
2015-02-11 17:37 Brian Dolbec
2015-02-11 17:37 Brian Dolbec
2015-02-11 17:37 Brian Dolbec
2015-02-11 17:37 Brian Dolbec
2015-02-11 17:37 Brian Dolbec
2015-02-11 17:37 Brian Dolbec
2015-02-11 17:37 Brian Dolbec
2015-01-09 21:07 Brian Dolbec
2015-01-09 21:07 Brian Dolbec
2015-01-09 21:07 Brian Dolbec
2015-01-09 21:07 Brian Dolbec
2015-01-09 21:07 Brian Dolbec
2015-01-09 21:07 Brian Dolbec
2015-01-09 21:07 Brian Dolbec
2015-01-08 4:13 Brian Dolbec
2015-01-07 23:39 Brian Dolbec
2015-01-05 23:12 Brian Dolbec
2015-01-05 23:12 Brian Dolbec
2015-01-05 23:12 Brian Dolbec
2015-01-05 23:12 Brian Dolbec
2015-01-05 23:12 Brian Dolbec
2015-01-05 23:12 Brian Dolbec
2015-01-05 23:12 Brian Dolbec
2015-01-05 23:12 Brian Dolbec
2015-01-01 22:32 Brian Dolbec
2015-01-01 17:44 Brian Dolbec
2015-01-01 17:44 Brian Dolbec
2015-01-01 17:44 Brian Dolbec
2015-01-01 17:44 Brian Dolbec
2015-01-01 17:44 Brian Dolbec
2014-12-31 21:34 Brian Dolbec
2014-12-31 21:34 Brian Dolbec
2014-12-31 21:34 Brian Dolbec
2014-12-31 21:34 Brian Dolbec
2014-12-31 21:34 Brian Dolbec
2014-12-31 21:34 Brian Dolbec
2014-12-31 21:34 Brian Dolbec
2014-12-31 21:34 Brian Dolbec
2014-12-31 21:34 Brian Dolbec
2014-12-31 21:34 Brian Dolbec
2014-12-31 21:34 Brian Dolbec
2014-12-31 21:34 Brian Dolbec
2014-12-31 21:34 Brian Dolbec
2014-12-31 21:34 Brian Dolbec
2014-12-26 18:37 Brian Dolbec
2014-12-26 18:37 Brian Dolbec
2014-12-26 18:37 Brian Dolbec
2014-12-26 5:02 Brian Dolbec
2014-12-26 5:02 Brian Dolbec
2014-12-26 5:02 Brian Dolbec
2014-12-25 22:07 Brian Dolbec
2014-12-25 22:07 Brian Dolbec
2014-12-25 20:43 Brian Dolbec
2014-12-25 20:43 Brian Dolbec
2014-12-25 20:43 Brian Dolbec
2014-12-24 19:59 Brian Dolbec
2014-12-24 19:59 Brian Dolbec
2014-12-24 19:59 Brian Dolbec
2014-12-24 19:59 Brian Dolbec
2014-12-24 19:59 Brian Dolbec
2014-12-24 19:59 Brian Dolbec
2014-12-24 19:59 Brian Dolbec
2014-12-24 19:59 Brian Dolbec
2014-12-23 2:50 Brian Dolbec
2014-12-23 2:50 Brian Dolbec
2014-12-23 0:13 Brian Dolbec
2014-12-22 23:11 Brian Dolbec
2014-12-22 23:11 Brian Dolbec
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1439049100.317de4981cc9208f5ff4595f048fb17f522283f6.dolsen@gentoo \
--to=dolsen@gentoo.org \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox