changeset 2:b8d620fa1116

solidify refactored workflow"
author Jeff Hammel <jhammel@mozilla.com>
date Mon, 10 May 2010 11:46:49 -0700
parents cc5add25bf83
children e700bd2ec289
files licenser/licenses.py licenser/main.py
diffstat 2 files changed, 20 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/licenser/licenses.py	Mon May 10 11:24:02 2010 -0700
+++ b/licenser/licenses.py	Mon May 10 11:46:49 2010 -0700
@@ -1,5 +1,4 @@
 import os
-
 from datetime import datetime
 
 class License(object):
@@ -15,12 +14,16 @@
     assert os.path.exists(self.template)
 
   def __call__(self, directory, **kw):
+    variables = self.obtain_variables(**kw)
+    self.interpolate(directory, variables)
+
+  def obtain_variables(self, **kw):
     for var in self.variables:
       if var not in kw:
         print 'Enter %s: ' % var,
         kw[var] = raw_input()
     self.pre(kw)
-    self.interpolate(directory, kw)
+    return kw
 
   def pre(self, variables):
     """do anything that needs to be done before interpolation"""
--- a/licenser/main.py	Mon May 10 11:24:02 2010 -0700
+++ b/licenser/main.py	Mon May 10 11:46:49 2010 -0700
@@ -22,6 +22,14 @@
         licenses[entry_point.name] = license
     return licenses
 
+def print_licenses(self, licenses):
+    for i in sorted(licenses.keys()):
+        doc = getattr(licenses[i], '__doc__')
+        if doc:
+            print '%s: %s' % (i, doc)
+        else:
+            print i
+
 
 def main(args=sys.argv[1:]):
     usage = '%prog [options] directory'
@@ -37,16 +45,17 @@
     licenses = license_list()
 
     if options.list: # list the licenses
-        for i in sorted(licenses.keys()):
-            doc = getattr(licenses[i], '__doc__')
-            if doc:
-                print '%s: %s' % (i, doc)
-            else:
-                print i
+        print_licenses(licenses)
         sys.exit(0)
 
     if not options.license:
         parser.error("Must specify --license")
+    if options.license not in licenses:
+        print_licenses(licenses)
+        
+    license = licenses[options.license]()
+    
+
 
     for directory in args:
         filelist = files(directory)