# HG changeset patch # User Jeff Hammel # Date 1389915871 28800 # Node ID 668b01d04457bba421e8542060247e92f6419504 # Parent 5fa35ff8664485cac10408ca530e1246a862aabf STUB: makeitso/makeitso.py makeitso/script2package.py diff -r 5fa35ff86644 -r 668b01d04457 makeitso/makeitso.py --- a/makeitso/makeitso.py Thu Jan 16 14:59:23 2014 -0800 +++ b/makeitso/makeitso.py Thu Jan 16 15:44:31 2014 -0800 @@ -1,6 +1,8 @@ #!/usr/bin/env python """ +boilerplate automation: + filesystem template interpreter """ @@ -425,7 +427,7 @@ default=True, action='store_false', help="don't read ~/.makeitso") - # TODO + # TODO: # parser.add_option('-u', '--update', dest='update', # help="update the specified .ini file for variables read from this run") # parser.add_option('-U', '--Update', dest='Update', diff -r 5fa35ff86644 -r 668b01d04457 makeitso/script2package.py --- a/makeitso/script2package.py Thu Jan 16 14:59:23 2014 -0800 +++ b/makeitso/script2package.py Thu Jan 16 15:44:31 2014 -0800 @@ -17,6 +17,15 @@ from .python import PythonModuleTemplate, PythonPackageTemplate +### name transformers.... -> ??? + +def scriptname2packagename(script): + return os.path.splitext(os.path.basename(script))[0] + + + +### CLI parsing + def add_options(parser): """add options to the OptionParser instance""" # TODO: replace with `configuration` package @@ -27,6 +36,7 @@ parser.add_option('-n', '--name', dest='name', help="Name of package; default taken from script name") parser.add_option('-o', '--output', dest='output', + default=os.getcwd(), help="where to output the resulting package [DEFAULT: '.']") def main(args=sys.argv[1:]): @@ -45,18 +55,36 @@ options, args = parser.parse_args(args) if len(args) != 1: parser.error("Please specify a source script") + script = args[0] + + # Get package name from script + if not options.name: + options.name = scriptname2packagename(script) # require a directory (for now) - # options.force = False # -> add_options - if os.path.exists(options.output) and not os.path.isdir(options.output): - parser.error("'%s' is a file" % options.output) + if os.path.exists(options.output): + if not os.path.isdir(options.output): + parser.error("'%s' is a file" % options.output) + options.output = os.path.join(options.output, options.name) + # XXX bad naming + else: + raise NotImplementedError("TODO") # configure template template = PythonModuleTemplate if options.py_module else PythonPackageTemplate + template = template() + # get some variables: + # - author + # - description + # - email + # - repo + # - url + variables = {} + # interpolate template + template.substitute() import pdb; pdb.set_trace() - # TODO if __name__ == '__main__':