commit:     c2e01ecee2f14ca8a4419433e43a50f5f7489376
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Wed Dec 31 02:50:20 2014 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Thu Jan  1 02:39:51 2015 +0000
URL:        
http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=c2e01ece

gkeys-gen: Add spec option

Action config changes

---
 gkeys-gen/gkeygen/actions.py | 13 ++++++++-----
 gkeys/gkeys/base.py          |  5 +++++
 2 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/gkeys-gen/gkeygen/actions.py b/gkeys-gen/gkeygen/actions.py
index b3aecb9..e329397 100644
--- a/gkeys-gen/gkeygen/actions.py
+++ b/gkeys-gen/gkeygen/actions.py
@@ -30,7 +30,7 @@ from gkeys.fileops import ensure_dirs
 Available_Actions = ["gen-key"]
 
 Action_Options = {
-    'gen-key': ['dest'],
+    'gen-key': ['dest', 'spec'],
 }
 
 Action_Map = {
@@ -77,7 +77,9 @@ class Actions(object):
                 return (False, messages)
         self.logger.debug("MAIN: _action_genkey; setting gpghome destination: 
%s" % gpghome)
         self.logger.debug("MAIN: _action_genkey; args= %s" % str(args))
-        key_params = self.get_input()
+        if not args.spec:
+            args.spec = self.config.get_key('spec', 'default-spec')
+        key_params = self.get_input(args)
         ack = None
         while ack not in ["y", "yes", "n", "no"]:
             ack = py_input("Continue?[y/n]: ").lower()
@@ -96,7 +98,7 @@ class Actions(object):
             newgpgconfpath = os.path.join(gpghome, 'gpg.conf')
             shutil.copy('/usr/share/gnupg/gpg-conf.skel', newgpgconfpath)
             with open(newgpgconfpath, 'a') as conf:
-                for line in urlopen(self.config.defaults['gpg.conf-url']):
+                for line in urlopen(self.config.get_key('gpg-urls', 
args.spec)):
                     conf.write(_unicode(line))
             # Key generation
             ctx = gpgme.Context()
@@ -125,7 +127,7 @@ class Actions(object):
             return (True, messages)
 
 
-    def get_input(self):
+    def get_input(self, args):
         '''Interactive user input'''
         self.output(["\nGPG key creator based on GLEP 63\n"
                     "(https://wiki.gentoo.org/wiki/GLEP:63)\n"])
@@ -135,6 +137,7 @@ class Actions(object):
             self.output(["\nBad email input. Try again."])
             email = py_input("Give your Email: ")
         print("\nReview:\n Full Name: %s\n Email: %s\n" % (name, email))
-        key_properties = urlopen(self.config.defaults['key-spec-url']).read()
+        url = self.config.get_key('spec-urls', args.spec)
+        key_properties = urlopen(url).read()
         return _unicode(key_properties).format(name, email)
 

diff --git a/gkeys/gkeys/base.py b/gkeys/gkeys/base.py
index 6e53f87..5c9505d 100644
--- a/gkeys/gkeys/base.py
+++ b/gkeys/gkeys/base.py
@@ -174,6 +174,11 @@ class CliBase(object):
            help='The path/URL to use for the signature')
 
     @staticmethod
+    def _option_spec(parser=None):
+        parser.add_argument('-S', '--spec', dest='spec', default=None,
+            help='The spec file to use from the gkeys-gen.conf file')
+
+    @staticmethod
     def _option_timestamp(parser=None):
         parser.add_argument('-t', '--timestamp', dest='timestamp',
             action='store_true', default=False,

Reply via email to