Revision 631b7c35 kamaki/cli/argument/__init__.py
b/kamaki/cli/argument/__init__.py | ||
---|---|---|
368 | 368 |
class ArgumentParseManager(object): |
369 | 369 |
"""Manage (initialize and update) an ArgumentParser object""" |
370 | 370 |
|
371 |
parser = None |
|
372 |
_arguments = {} |
|
373 |
_parser_modified = False |
|
374 |
_parsed = None |
|
375 |
_unparsed = None |
|
376 |
|
|
377 | 371 |
def __init__(self, exe, arguments=None): |
378 | 372 |
""" |
379 | 373 |
:param exe: (str) the basic command (e.g. 'kamaki') |
... | ... | |
389 | 383 |
else: |
390 | 384 |
global _arguments |
391 | 385 |
self.arguments = _arguments |
386 |
self._parser_modified, self._parsed, self._unparsed = False, None, None |
|
392 | 387 |
self.parse() |
393 | 388 |
|
394 | 389 |
@property |
... | ... | |
402 | 397 |
|
403 | 398 |
@property |
404 | 399 |
def arguments(self): |
405 |
"""(dict) arguments the parser should be aware of""" |
|
400 |
""":returns: (dict) arguments the parser should be aware of"""
|
|
406 | 401 |
return self._arguments |
407 | 402 |
|
408 | 403 |
@arguments.setter |
409 | 404 |
def arguments(self, new_arguments): |
410 |
if new_arguments: |
|
411 |
assert isinstance(new_arguments, dict) |
|
405 |
assert isinstance(new_arguments, dict), 'Arguments must be in a dict' |
|
412 | 406 |
self._arguments = new_arguments |
413 | 407 |
self.update_parser() |
414 | 408 |
|
... | ... | |
431 | 425 |
|
432 | 426 |
:param arguments: if not given, update self.arguments instead |
433 | 427 |
""" |
434 |
if not arguments: |
|
435 |
arguments = self._arguments |
|
428 |
arguments = arguments or self._arguments |
|
436 | 429 |
|
437 | 430 |
for name, arg in arguments.items(): |
438 | 431 |
try: |
Also available in: Unified diff