Revision 5a37a189 kamaki/cli/commands/__init__.py
b/kamaki/cli/commands/__init__.py | ||
---|---|---|
39 | 39 |
|
40 | 40 |
class _command_init(object): |
41 | 41 |
def __init__(self, arguments={}): |
42 |
self.arguments = arguments |
|
42 |
if not hasattr(self, 'arguments'): |
|
43 |
self.arguments = {} |
|
44 |
self.arguments.update(arguments) |
|
43 | 45 |
try: |
44 |
self.config = self.get_argument('config') |
|
46 |
self.config = self['config'].value |
|
47 |
#self.config = self.get_argument('config') |
|
45 | 48 |
except KeyError: |
46 | 49 |
pass |
47 | 50 |
|
51 |
def __getitem__(self, argterm): |
|
52 |
""" |
|
53 |
:param argterm: (str) the name/label of an argument in self.arguments |
|
54 |
|
|
55 |
:returns: (Argument) |
|
56 |
|
|
57 |
:raises KeyError: if argterm not in self.arguments of this object |
|
58 |
""" |
|
59 |
return self.arguments[argterm] |
|
60 |
|
|
61 |
def __setitem__(self, argterm, arg): |
|
62 |
"""Install an argument as argterm |
|
63 |
If argterm points to another argument, the other argument is lost |
|
64 |
|
|
65 |
:param argterm: (str) |
|
66 |
|
|
67 |
:param arg: (Argument) |
|
68 |
""" |
|
69 |
if not hasattr(self, 'arguments'): |
|
70 |
self.arguments = {} |
|
71 |
self.arguments[argterm] = arg |
|
72 |
|
|
48 | 73 |
def get_argument(self, argterm): |
74 |
""" |
|
75 |
:param argterm: (str) the name/label of an argument in self.arguments |
|
76 |
|
|
77 |
:returns: the value of the arument object |
|
78 |
|
|
79 |
:raises KeyError: if argterm not in self.arguments of this object |
|
80 |
""" |
|
49 | 81 |
return self.arguments[argterm].value |
Also available in: Unified diff