Changeset 411
- Timestamp:
- 05/07/07 02:06:32 (2 years ago)
- Files:
-
- cly/trunk/cly/__init__.py (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
cly/trunk/cly/__init__.py
r408 r411 379 379 posixpath.join(self.path(), self._alias))) 380 380 381 def __init__(self, alias, * *options):382 Node.__init__(self, "<alias for '%s'>" % alias, * *options)381 def __init__(self, alias, *args, **kwargs): 382 Node.__init__(self, "<alias for '%s'>" % alias, *args, **kwargs) 383 383 self._alias = alias 384 384 … … 428 428 with_context = False 429 429 430 def __init__(self, help, callback=None, * *kwargs):430 def __init__(self, help, callback=None, *args, **kwargs): 431 431 if isinstance(help, basestring): 432 432 help_string = help 433 433 help = lambda ctx: (('<eol>', help_string),) 434 Node.__init__(self, help, callback=callback, * *kwargs)434 Node.__init__(self, help, callback=callback, *args, **kwargs) 435 435 436 436 def help(self, context): … … 460 460 """Validate and record the users input in the vars member of the context. 461 461 462 The Node name is used as the variable name. 462 The Node name is used as the variable name unless var_name is provided to 463 the constructor. 463 464 464 465 If traversals is > 1 the validator will accumulate values into a list. … … 466 467 467 468 pattern = r'\w+' 469 470 def __init__(self, help, var_name=None, *args, **kwargs): 471 Node.__init__(self, help, *args, **kwargs) 472 self._var_name = var_name 473 474 def _get_var_name(self): 475 """Get the var name for this validator. Will use `var_name` if provided 476 to the constructor, otherwise it will use the node name.""" 477 if self._var_name is not None: 478 return self._var_name 479 return self.name 480 481 var_name = property(_get_var_name) 468 482 469 483 def valid(self, context): … … 492 506 exception=unicode(e)) 493 507 if self.traversals > 1: 494 context.vars.setdefault(self. name, []).append(value)508 context.vars.setdefault(self.var_name, []).append(value) 495 509 else: 496 context.vars[self. name] = value510 context.vars[self.var_name] = value 497 511 return Node.selected(self, context, match) 498 512
