Mercurial > hg > MakeItSo
annotate makeitso/python_module/{{module}}.py @ 151:e70421c50d0a
move to ABC
| author | Jeff Hammel <jhammel@mozilla.com> |
|---|---|
| date | Sat, 01 Dec 2012 19:01:18 -0800 |
| parents | a203f79c537f |
| children | 88f5bab340a1 |
| rev | line source |
|---|---|
|
129
57834c2b0937
add a single-file module to the thingy
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
1 #!/usr/bin/env python |
|
57834c2b0937
add a single-file module to the thingy
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
2 |
|
57834c2b0937
add a single-file module to the thingy
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
3 """ |
|
57834c2b0937
add a single-file module to the thingy
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
4 {{module}} |
|
57834c2b0937
add a single-file module to the thingy
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
5 """ |
|
57834c2b0937
add a single-file module to the thingy
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
6 |
|
57834c2b0937
add a single-file module to the thingy
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
7 import sys |
|
130
d9201f911458
better description formatting
Jeff Hammel <jhammel@mozilla.com>
parents:
129
diff
changeset
|
8 import optparse |
|
129
57834c2b0937
add a single-file module to the thingy
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
9 |
|
57834c2b0937
add a single-file module to the thingy
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
10 def main(args=sys.argv[1:]): |
|
57834c2b0937
add a single-file module to the thingy
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
11 |
|
57834c2b0937
add a single-file module to the thingy
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
12 # parse command line arguments |
|
57834c2b0937
add a single-file module to the thingy
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
13 usage = '%prog [options] ...' |
|
130
d9201f911458
better description formatting
Jeff Hammel <jhammel@mozilla.com>
parents:
129
diff
changeset
|
14 class PlainDescriptionFormatter(optparse.IndentedHelpFormatter): |
| 142 | 15 """description formatter""" |
|
130
d9201f911458
better description formatting
Jeff Hammel <jhammel@mozilla.com>
parents:
129
diff
changeset
|
16 def format_description(self, description): |
|
d9201f911458
better description formatting
Jeff Hammel <jhammel@mozilla.com>
parents:
129
diff
changeset
|
17 if description: |
|
d9201f911458
better description formatting
Jeff Hammel <jhammel@mozilla.com>
parents:
129
diff
changeset
|
18 return description + '\n' |
|
d9201f911458
better description formatting
Jeff Hammel <jhammel@mozilla.com>
parents:
129
diff
changeset
|
19 else: |
|
d9201f911458
better description formatting
Jeff Hammel <jhammel@mozilla.com>
parents:
129
diff
changeset
|
20 return '' |
|
d9201f911458
better description formatting
Jeff Hammel <jhammel@mozilla.com>
parents:
129
diff
changeset
|
21 parser = optparse.OptionParser(usage=usage, description=__doc__, formatter=PlainDescriptionFormatter()) |
|
129
57834c2b0937
add a single-file module to the thingy
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
22 options, args = parser.parse_args(args) |
|
57834c2b0937
add a single-file module to the thingy
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
23 |
|
57834c2b0937
add a single-file module to the thingy
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
24 if __name__ == '__main__': |
|
57834c2b0937
add a single-file module to the thingy
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
25 main() |
