annotate makeitso/python.py @ 108:32893f67f85d

stub out a better python package
author Jeff Hammel <jhammel@mozilla.com>
date Fri, 14 Jan 2011 07:35:19 -0800
parents ad5fd3eb6674
children 697568ba4a22
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
78
d4184945f8a8 stub out python package creation
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
1 #!/usr/bin/env python
d4184945f8a8 stub out python package creation
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
2
d4184945f8a8 stub out python package creation
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
3 """
d4184945f8a8 stub out python package creation
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
4 python package templates for makeitso
d4184945f8a8 stub out python package creation
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
5
d4184945f8a8 stub out python package creation
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
6 Several components are included.
d4184945f8a8 stub out python package creation
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
7 [TODO] You may use these subtemplates in any combination.
d4184945f8a8 stub out python package creation
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
8
d4184945f8a8 stub out python package creation
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
9 * README.txt : a README in restructured text
d4184945f8a8 stub out python package creation
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
10 * examples : examples for your package
d4184945f8a8 stub out python package creation
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
11 * setup.py : setup utility for the full package
d4184945f8a8 stub out python package creation
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
12 * ./main.py : CLI handler for your webapp
d4184945f8a8 stub out python package creation
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
13 * ./model.py : model of a persisted object
d4184945f8a8 stub out python package creation
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
14 * ./template.py : a MakeItSo template for project creation
d4184945f8a8 stub out python package creation
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
15 * ./tests : doctest suite for the package
d4184945f8a8 stub out python package creation
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
16 * ./web.py : a webob web handler
d4184945f8a8 stub out python package creation
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
17 """
d4184945f8a8 stub out python package creation
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
18
d4184945f8a8 stub out python package creation
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
19 import sys
d4184945f8a8 stub out python package creation
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
20 from cli import MakeItSoCLI
d4184945f8a8 stub out python package creation
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
21 from optparse import OptionParser
d4184945f8a8 stub out python package creation
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
22 from template import MakeItSoTemplate
108
32893f67f85d stub out a better python package
Jeff Hammel <jhammel@mozilla.com>
parents: 102
diff changeset
23 from template import Variable
78
d4184945f8a8 stub out python package creation
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
24
102
ad5fd3eb6674 template fixes....not the best, but will do
Jeff Hammel <jhammel@mozilla.com>
parents: 95
diff changeset
25 class PythonPackageTemplate(MakeItSoTemplate):
78
d4184945f8a8 stub out python package creation
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
26 """
d4184945f8a8 stub out python package creation
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
27 python package template
d4184945f8a8 stub out python package creation
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
28 """
d4184945f8a8 stub out python package creation
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
29 name = 'python-package'
d4184945f8a8 stub out python package creation
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
30 templates = ['python_package']
108
32893f67f85d stub out a better python package
Jeff Hammel <jhammel@mozilla.com>
parents: 102
diff changeset
31 vars = [Variable('description'),
32893f67f85d stub out a better python package
Jeff Hammel <jhammel@mozilla.com>
parents: 102
diff changeset
32 Variable('url'),
32893f67f85d stub out a better python package
Jeff Hammel <jhammel@mozilla.com>
parents: 102
diff changeset
33 Variable('repo', 'project repository'),
32893f67f85d stub out a better python package
Jeff Hammel <jhammel@mozilla.com>
parents: 102
diff changeset
34 ]
78
d4184945f8a8 stub out python package creation
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
35 look = True
d4184945f8a8 stub out python package creation
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
36
d4184945f8a8 stub out python package creation
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
37 # things that go in setup.py
d4184945f8a8 stub out python package creation
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
38 dependencies = {'web.py': ['webob'],
d4184945f8a8 stub out python package creation
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
39 'template.py': ['MakeItSo']}
d4184945f8a8 stub out python package creation
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
40 console_scripts = {'main.py': '{{project}}.main:main',
d4184945f8a8 stub out python package creation
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
41 'template.py': '{{project}}.template:main'
d4184945f8a8 stub out python package creation
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
42 }
d4184945f8a8 stub out python package creation
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
43
d4184945f8a8 stub out python package creation
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
44 def __init__(self, **kw):
d4184945f8a8 stub out python package creation
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
45 MakeItSoTemplate.__init__(self, **kw)
d4184945f8a8 stub out python package creation
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
46
108
32893f67f85d stub out a better python package
Jeff Hammel <jhammel@mozilla.com>
parents: 102
diff changeset
47 def pre(self, variables, output):
32893f67f85d stub out a better python package
Jeff Hammel <jhammel@mozilla.com>
parents: 102
diff changeset
48 """
32893f67f85d stub out a better python package
Jeff Hammel <jhammel@mozilla.com>
parents: 102
diff changeset
49 sanitize some variables
32893f67f85d stub out a better python package
Jeff Hammel <jhammel@mozilla.com>
parents: 102
diff changeset
50 """
32893f67f85d stub out a better python package
Jeff Hammel <jhammel@mozilla.com>
parents: 102
diff changeset
51
32893f67f85d stub out a better python package
Jeff Hammel <jhammel@mozilla.com>
parents: 102
diff changeset
52 # dependencies
32893f67f85d stub out a better python package
Jeff Hammel <jhammel@mozilla.com>
parents: 102
diff changeset
53 dependencies = []
32893f67f85d stub out a better python package
Jeff Hammel <jhammel@mozilla.com>
parents: 102
diff changeset
54
32893f67f85d stub out a better python package
Jeff Hammel <jhammel@mozilla.com>
parents: 102
diff changeset
55 # console_scripts
32893f67f85d stub out a better python package
Jeff Hammel <jhammel@mozilla.com>
parents: 102
diff changeset
56 console_scripts = []
32893f67f85d stub out a better python package
Jeff Hammel <jhammel@mozilla.com>
parents: 102
diff changeset
57
102
ad5fd3eb6674 template fixes....not the best, but will do
Jeff Hammel <jhammel@mozilla.com>
parents: 95
diff changeset
58 class PythonPackageCLI(MakeItSoCLI):
ad5fd3eb6674 template fixes....not the best, but will do
Jeff Hammel <jhammel@mozilla.com>
parents: 95
diff changeset
59 """
ad5fd3eb6674 template fixes....not the best, but will do
Jeff Hammel <jhammel@mozilla.com>
parents: 95
diff changeset
60 CLI front end for the python package template
ad5fd3eb6674 template fixes....not the best, but will do
Jeff Hammel <jhammel@mozilla.com>
parents: 95
diff changeset
61 """
95
e74baa8e6df4 fix CLI interface a bit....write a test for it
Jeff Hammel <jhammel@mozilla.com>
parents: 78
diff changeset
62
102
ad5fd3eb6674 template fixes....not the best, but will do
Jeff Hammel <jhammel@mozilla.com>
parents: 95
diff changeset
63 def main(args=sys.argv[1:]):
ad5fd3eb6674 template fixes....not the best, but will do
Jeff Hammel <jhammel@mozilla.com>
parents: 95
diff changeset
64 cli = PythonPackageCLI(PythonPackageTemplate)
ad5fd3eb6674 template fixes....not the best, but will do
Jeff Hammel <jhammel@mozilla.com>
parents: 95
diff changeset
65 cli(*args)
78
d4184945f8a8 stub out python package creation
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
66
d4184945f8a8 stub out python package creation
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
67 if __name__ == '__main__':
d4184945f8a8 stub out python package creation
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
68 main()