Mercurial > hg > MakeItSo
changeset 176:668b01d04457
STUB: makeitso/makeitso.py makeitso/script2package.py
author | Jeff Hammel <k0scist@gmail.com> |
---|---|
date | Thu, 16 Jan 2014 15:44:31 -0800 |
parents | 5fa35ff86644 |
children | c3f719824948 |
files | makeitso/makeitso.py makeitso/script2package.py |
diffstat | 2 files changed, 35 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- 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',
--- 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__':