changeset 174:aed8c4af5f26

STUB: makeitso/cli.py makeitso/script2package.py setup.py
author Jeff Hammel <k0scist@gmail.com>
date Thu, 16 Jan 2014 13:31:54 -0800
parents ceb8c8042e48
children 5fa35ff86644
files makeitso/cli.py makeitso/script2package.py setup.py
diffstat 3 files changed, 28 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/makeitso/cli.py	Wed Dec 11 04:57:15 2013 -0800
+++ b/makeitso/cli.py	Thu Jan 16 13:31:54 2014 -0800
@@ -7,7 +7,7 @@
 
 class MakeItSoCLI(object):
   """command line interface to a makeitso template"""
-  
+
   def __init__(self, template_class):
     self.template_class = template_class
 
@@ -50,11 +50,12 @@
 
     # template variables
     variables = self.get_variables(options)
-    
+
     # return the variables and the output
     return variables, args[0]
-    
+
   def __call__(self, *args):
+    """interpolate template"""
     variables, output = self.parse(list(args))
     template = self.template_class(variables=variables)
     template.substitute({}, output=output)
--- a/makeitso/script2package.py	Wed Dec 11 04:57:15 2013 -0800
+++ b/makeitso/script2package.py	Thu Jan 16 13:31:54 2014 -0800
@@ -15,13 +15,24 @@
 import subprocess
 import sys
 
+from .python import PythonModuleTemplate, PythonPackageTemplate
+
 def add_options(parser):
     """add options to the OptionParser instance"""
+    # TODO: replace with `configuration` package
+
+    parser.add_option('-m', '--module', dest='py_module',
+                      action='store_true', default=False,
+                      help="create a single-module package with py_modules in setup.py")
+    parser.add_option('-n', '--name', dest='name',
+                      help="Name of package; default taken from script name")
+    parser.add_option('-o', '--output', dest='output',
+                      help="where to output the resulting package [DEFAULT: '.']")
 
 def main(args=sys.argv[1:]):
 
     # parse command line options
-    usage = '%prog [options] ...'
+    usage = '%prog [options] script.py'
     class PlainDescriptionFormatter(optparse.IndentedHelpFormatter):
         """description formatter for console script entry point"""
         def format_description(self, description):
@@ -30,8 +41,18 @@
             else:
                 return ''
     parser = optparse.OptionParser(usage=usage, description=__doc__, formatter=PlainDescriptionFormatter())
+    add_options(parser)
     options, args = parser.parse_args(args)
+    if len(args) != 1:
+        parser.error("Please specify a source script")
+
+    # configure template
+    template = PythonModuleTemplate if options.py_module else PythonPackageTemplate
+
+    # interpolate template
+    
+    
+    # TODO
 
 if __name__ == '__main__':
   main()
-
--- a/setup.py	Wed Dec 11 04:57:15 2013 -0800
+++ b/setup.py	Thu Jan 16 13:31:54 2014 -0800
@@ -33,6 +33,7 @@
       makeitso = makeitso.makeitso:main
       make-python-package = makeitso.python:main
       mkpydir = makeitso.mkpydir:main
+      script2package = makeitso.script2package:main
 
       [makeitso.templates]
       python-package = makeitso.python:PythonPackageTemplate