Mercurial > hg > MakeItSo
changeset 160:9033a5f11b92
wip
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Tue, 30 Jul 2013 15:29:56 -0700 |
parents | cfd4f1e91090 |
children | a5d058957734 |
files | makeitso/python.py makeitso/python_module/{{module}}.py makeitso/python_package/{{package}}/main.py makeitso/python_package/{{package}}/{{main}}.py |
diffstat | 4 files changed, 38 insertions(+), 63 deletions(-) [+] |
line wrap: on
line diff
--- a/makeitso/python.py Tue Jul 30 15:20:38 2013 -0700 +++ b/makeitso/python.py Tue Jul 30 15:29:56 2013 -0700 @@ -26,6 +26,12 @@ class PythonTemplate(MakeItSoTemplate): """abstract base class for python-type templates""" + vars = [Variable('description'), + Variable('author', 'author of the package'), + Variable('email', "author's email"), + Variable('url', 'project url'), + Variable('repo', 'project repository'), + ] def path2name(self, path): return os.path.basename(path.rstrip(os.path.sep)) @@ -33,7 +39,7 @@ class PythonScriptTemplate(PythonTemplate): """template for a single python script""" templates = [('python_package', '{{package}}', '{{main}}.py')] - + vars = [Variable('description')] class PythonModuleTemplate(PythonTemplate): """single module python package"""
--- a/makeitso/python_module/{{module}}.py Tue Jul 30 15:20:38 2013 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,31 +0,0 @@ -#!/usr/bin/env python - -""" -{{module}} -{{description}} -""" - -import optparse -import sys - -def add_options(parser): - """add {{module}} options to an OptionParser instance""" - - -def main(args=sys.argv[1:]): - - # parse command line arguments - usage = '%prog [options] ...' - class PlainDescriptionFormatter(optparse.IndentedHelpFormatter): - """description formatter""" - def format_description(self, description): - if description: - return description.strip() + '\n' - else: - return '' - parser = optparse.OptionParser(usage=usage, description=__doc__, formatter=PlainDescriptionFormatter()) - add_options(parser) - options, args = parser.parse_args(args) - -if __name__ == '__main__': - main()
--- a/makeitso/python_package/{{package}}/main.py Tue Jul 30 15:20:38 2013 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,31 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -""" -{{description}} -""" - -import optparse -import os -import subprocess -import sys - -def add_options(parser): - """add {{package}} options to an OptionParser instance""" - -def main(args=sys.argv[1:]): - - # parse command line options - usage = '%prog [options] ...' - class PlainDescriptionFormatter(optparse.IndentedHelpFormatter): - """description formatter for console script entry point""" - def format_description(self, description): - if description: - return description.strip() + '\n' - else: - return '' - parser = optparse.OptionParser(usage=usage, description=__doc__, formatter=PlainDescriptionFormatter()) - options, args = parser.parse_args(args) - -if __name__ == '__main__': - main()
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/makeitso/python_package/{{package}}/{{main}}.py Tue Jul 30 15:29:56 2013 -0700 @@ -0,0 +1,31 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +""" +{{description}} +""" + +import optparse +import os +import subprocess +import sys + +def add_options(parser): + """add {{package}} options to an OptionParser instance""" + +def main(args=sys.argv[1:]): + + # parse command line options + usage = '%prog [options] ...' + class PlainDescriptionFormatter(optparse.IndentedHelpFormatter): + """description formatter for console script entry point""" + def format_description(self, description): + if description: + return description.strip() + '\n' + else: + return '' + parser = optparse.OptionParser(usage=usage, description=__doc__, formatter=PlainDescriptionFormatter()) + options, args = parser.parse_args(args) + +if __name__ == '__main__': + main()