# HG changeset patch # User Jeff Hammel # Date 1294538098 28800 # Node ID d4184945f8a86f7a08e01923c281f6d98959e037 # Parent 059b02808efaf7ae9c469c032980678d405bbd4d stub out python package creation diff -r 059b02808efa -r d4184945f8a8 makeitso/python.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/makeitso/python.py Sat Jan 08 17:54:58 2011 -0800 @@ -0,0 +1,48 @@ +#!/usr/bin/env python + +""" +python package templates for makeitso + +Several components are included. +[TODO] You may use these subtemplates in any combination. + +* README.txt : a README in restructured text +* examples : examples for your package +* setup.py : setup utility for the full package +* ./main.py : CLI handler for your webapp +* ./model.py : model of a persisted object +* ./template.py : a MakeItSo template for project creation +* ./tests : doctest suite for the package +* ./web.py : a webob web handler +""" + +import sys +from cli import MakeItSoCLI +from optparse import OptionParser +from template import MakeItSoTemplate + +class PythonPackage(MakeItSoTemplate): + """ + python package template + """ + name = 'python-package' + templates = ['python_package'] + look = True + + # things that go in setup.py + dependencies = {'web.py': ['webob'], + 'template.py': ['MakeItSo']} + console_scripts = {'main.py': '{{project}}.main:main', + 'template.py': '{{project}}.template:main' + } + + def __init__(self, **kw): + MakeItSoTemplate.__init__(self, **kw) + +def main(args=sys.argv[:]): + usage = '%prog [options]' + + +if __name__ == '__main__': + main() + diff -r 059b02808efa -r d4184945f8a8 makeitso/python_package/README.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/makeitso/python_package/README.txt Sat Jan 08 17:54:58 2011 -0800 @@ -0,0 +1,1 @@ +Example single-file templates diff -r 059b02808efa -r d4184945f8a8 makeitso/python_package/script.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/makeitso/python_package/script.py Sat Jan 08 17:54:58 2011 -0800 @@ -0,0 +1,16 @@ +#!/usr/bin/env python + +""" +{{description}} +""" + +import sys +from optparse import OptionParser + +def main(args=sys.argv[:]): + usage = '%prog [options]' + parser = OptionParser(usage=usage, description=__doc__) + options, args = parser.parse_args(args) + +if __name__ == '__main__': + main() diff -r 059b02808efa -r d4184945f8a8 makeitso/template.py --- a/makeitso/template.py Sat Jan 08 16:21:29 2011 -0800 +++ b/makeitso/template.py Sat Jan 08 17:54:58 2011 -0800 @@ -96,6 +96,8 @@ # boilerplate variables = variables or {} self.output = output + if not self.description and hasattr(self, '__doc__'): + self.description = self.__doc__ self.interactive = interactive _file = sys.modules[self.__class__.__module__].__file__ self.location = os.path.dirname(os.path.abspath(_file)) diff -r 059b02808efa -r d4184945f8a8 templates/README.txt --- a/templates/README.txt Sat Jan 08 16:21:29 2011 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -Example single-file templates diff -r 059b02808efa -r d4184945f8a8 templates/script.py --- a/templates/script.py Sat Jan 08 16:21:29 2011 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,16 +0,0 @@ -#!/usr/bin/env python - -""" -{{description}} -""" - -import sys -from optparse import OptionParser - -def main(args=sys.argv[:]): - usage = '%prog [options]' - parser = OptionParser(usage=usage, description=__doc__) - options, args = parser.parse_args(args) - -if __name__ == '__main__': - main()