Mercurial > hg > MakeItSo
annotate makeitso/python.py @ 102:ad5fd3eb6674
template fixes....not the best, but will do
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Tue, 11 Jan 2011 16:30:52 -0800 |
parents | e74baa8e6df4 |
children | 32893f67f85d |
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 |
d4184945f8a8
stub out python package creation
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
23 |
102
ad5fd3eb6674
template fixes....not the best, but will do
Jeff Hammel <jhammel@mozilla.com>
parents:
95
diff
changeset
|
24 class PythonPackageTemplate(MakeItSoTemplate): |
78
d4184945f8a8
stub out python package creation
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
25 """ |
d4184945f8a8
stub out python package creation
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
26 python package template |
d4184945f8a8
stub out python package creation
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
27 """ |
d4184945f8a8
stub out python package creation
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
28 name = 'python-package' |
d4184945f8a8
stub out python package creation
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
29 templates = ['python_package'] |
d4184945f8a8
stub out python package creation
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
30 look = True |
d4184945f8a8
stub out python package creation
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
31 |
d4184945f8a8
stub out python package creation
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
32 # things that go in setup.py |
d4184945f8a8
stub out python package creation
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
33 dependencies = {'web.py': ['webob'], |
d4184945f8a8
stub out python package creation
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
34 'template.py': ['MakeItSo']} |
d4184945f8a8
stub out python package creation
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
35 console_scripts = {'main.py': '{{project}}.main:main', |
d4184945f8a8
stub out python package creation
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
36 'template.py': '{{project}}.template:main' |
d4184945f8a8
stub out python package creation
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
37 } |
d4184945f8a8
stub out python package creation
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
38 |
d4184945f8a8
stub out python package creation
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
39 def __init__(self, **kw): |
d4184945f8a8
stub out python package creation
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
40 MakeItSoTemplate.__init__(self, **kw) |
d4184945f8a8
stub out python package creation
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
41 |
102
ad5fd3eb6674
template fixes....not the best, but will do
Jeff Hammel <jhammel@mozilla.com>
parents:
95
diff
changeset
|
42 class PythonPackageCLI(MakeItSoCLI): |
ad5fd3eb6674
template fixes....not the best, but will do
Jeff Hammel <jhammel@mozilla.com>
parents:
95
diff
changeset
|
43 """ |
ad5fd3eb6674
template fixes....not the best, but will do
Jeff Hammel <jhammel@mozilla.com>
parents:
95
diff
changeset
|
44 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
|
45 """ |
95
e74baa8e6df4
fix CLI interface a bit....write a test for it
Jeff Hammel <jhammel@mozilla.com>
parents:
78
diff
changeset
|
46 |
102
ad5fd3eb6674
template fixes....not the best, but will do
Jeff Hammel <jhammel@mozilla.com>
parents:
95
diff
changeset
|
47 def main(args=sys.argv[1:]): |
ad5fd3eb6674
template fixes....not the best, but will do
Jeff Hammel <jhammel@mozilla.com>
parents:
95
diff
changeset
|
48 cli = PythonPackageCLI(PythonPackageTemplate) |
ad5fd3eb6674
template fixes....not the best, but will do
Jeff Hammel <jhammel@mozilla.com>
parents:
95
diff
changeset
|
49 cli(*args) |
78
d4184945f8a8
stub out python package creation
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
50 |
d4184945f8a8
stub out python package creation
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
51 if __name__ == '__main__': |
d4184945f8a8
stub out python package creation
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
52 main() |