[Checkins] SVN: grokproject/trunk/ Use vars and template_main parameters in main function so it can be reused

Vincent Fretin vincent.fretin at gmail.com
Fri Dec 31 09:58:14 EST 2010


Log message for revision 119233:
  Use vars and template_main parameters in main function so it can be reused
  in dolmenproject.
  

Changed:
  U   grokproject/trunk/CHANGES.txt
  U   grokproject/trunk/grokproject/main.py

-=-
Modified: grokproject/trunk/CHANGES.txt
===================================================================
--- grokproject/trunk/CHANGES.txt	2010-12-31 14:14:54 UTC (rev 119232)
+++ grokproject/trunk/CHANGES.txt	2010-12-31 14:58:13 UTC (rev 119233)
@@ -6,6 +6,8 @@
 
 - Added include_site_packages, install_requires, and additional_grants
   variables in the template for use in dolmenproject.
+  Use vars and template_main parameters in main function so it can be reused
+  in dolmenproject.
 
 2.2 (2010-11-26)
 ----------------

Modified: grokproject/trunk/grokproject/main.py
===================================================================
--- grokproject/trunk/grokproject/main.py	2010-12-31 14:14:54 UTC (rev 119232)
+++ grokproject/trunk/grokproject/main.py	2010-12-31 14:58:13 UTC (rev 119233)
@@ -7,7 +7,7 @@
 
 project_name_re=re.compile('[a-zA-Z_][a-zA-Z0-9_]*')
 
-def main():
+def main(vars=GrokProject.vars, template_name='grok'):
     usage = "usage: %prog [options] PROJECT"
     parser = optparse.OptionParser(usage=usage)
     parser.add_option(
@@ -28,7 +28,7 @@
         help="Show grokproject version.")
 
     # Options that override the interactive part of filling the templates.
-    for var in GrokProject.vars:
+    for var in vars:
         option_name = '--'+var.name.replace('_', '-')
         if not parser.has_option(option_name):
             parser.add_option(
@@ -60,7 +60,7 @@
     # Process the options that override the interactive part of filling
     # the templates.
     extra_args = []
-    for var in GrokProject.vars:
+    for var in vars:
         supplied_value = getattr(options, var.name)
         if supplied_value is not None:
             extra_args.append('%s=%s' % (var.name, supplied_value))
@@ -76,7 +76,7 @@
         sys.exit(1)
 
     # Create the project.
-    exit_code = runner.run(option_args + ['-t', 'grok', project] + extra_args)
+    exit_code = runner.run(option_args + ['-t', template_name, project] + extra_args)
     sys.exit(exit_code)
 
 def get_version():



More information about the checkins mailing list