Mercurial > hg > CommandParser
comparison commandparser/command.py @ 9:0069096e8e22
python 2.4 compatability
| author | Jeff Hammel <jhammel@mozilla.com> |
|---|---|
| date | Fri, 30 Mar 2012 16:45:50 -0700 |
| parents | 109627b7db9f |
| children | a3599e4db9a4 |
comparison
equal
deleted
inserted
replaced
| 8:109627b7db9f | 9:0069096e8e22 |
|---|---|
| 1 """ | 1 """ |
| 2 a command-line interface to the command line, a la pythonpaste | 2 a command-line interface to the command line, a la pythonpaste |
| 3 """ | 3 """ |
| 4 | 4 |
| 5 import inspect | 5 import inspect |
| 6 import json | |
| 7 import os | 6 import os |
| 8 import sys | 7 import sys |
| 9 from optparse import OptionParser | 8 from optparse import OptionParser |
| 10 from pprint import pprint | 9 from pprint import pprint |
| 11 | 10 |
| 11 try: | |
| 12 import json | |
| 13 except ImportError: | |
| 14 import simplejson as json | |
| 15 | |
| 12 __all__ = ['Undefined', 'CommandParser'] | 16 __all__ = ['Undefined', 'CommandParser'] |
| 13 | 17 |
| 14 class Undefined(object): | 18 class Undefined(object): |
| 15 def __init__(self, default): | 19 def __init__(self, default): |
| 16 self.default=default | 20 self.default=default |
| 17 | 21 |
| 18 class CommandParser(OptionParser): | 22 class CommandParser(OptionParser): |
| 19 # TODO: add `help` command | 23 # TODO: add `help` command |
| 20 | 24 |
| 21 def __init__(self, _class, description=None): | 25 def __init__(self, _class, description=None): |
