class Option():
Instance attributes:
_short_opts : [string]
_long_opts : [string]
action : string
type : string
dest : string
default : any
nargs : int
const : any
choices : [string]
callback : function
callback_args : (any*)
callback_kwargs : { string : any }
help : string
metavar : string
class attributes and properties:
ACTIONS: ('store', 'store_const', 'store_true', 'store_false', 'append', 'count', 'callback', 'help', 'versio...
ALWAYS_TYPED_ACTIONS: ('store', 'append')
ATTRS: ['action', 'type', 'dest', 'default', 'nargs', 'const', 'choices', 'callback', 'callback_args', 'cal...
CHECK_METHODS: [<function _check_action at 0x30163270>, <function _check_type at 0x301632b0>, <function _check_choi...
STORE_ACTIONS: ('store', 'store_const', 'store_true', 'store_false', 'append', 'count')
TYPED_ACTIONS: ('store', 'append', 'callback')
TYPES: ('string', 'int', 'long', 'float', 'complex', 'choice')
TYPE_CHECKER: {'int': <function check_builtin at 0x30162ab0>, 'float': <function check_builtin at 0x30162ab0>, 'co...
methods:
def __init__(self, *opts, **attrs):
*no docstring available*
arguments:
return value:
<None>
source: compat/optparse.py
491 |
492 |
493 |
494 |
495 |
496 |
497 |
498 |
499 |
500 |
501 |
502 |
503 |
504 |
505 |
506 |
507 |
508 | |
def __init__(self, *opts, **attrs): |
|
|
self._short_opts = [] |
self._long_opts = [] |
opts = self._check_opt_strings(opts) |
self._set_opt_strings(opts) |
|
|
self._set_attrs(attrs) |
|
|
|
|
|
|
for checker in self.CHECK_METHODS: |
checker(self) | |
def check_value(self, opt, value):
*no docstring available*
arguments:
- self: <Instance of Class Option>
- opt: <String>
- value: <String>
return value:
<String>
source: compat/optparse.py
|
def check_value(self, opt, value): |
checker = self.TYPE_CHECKER.get(self.type) |
if checker is None: |
return value |
else: |
return checker(self, opt, value) | |
def convert_value(self, opt, value):
*no docstring available*
arguments:
- self: <UNKNOWN>
- opt: <UNKNOWN>
- value: <UNKNOWN>
return value:
<UNKNOWN>
source: compat/optparse.py
|
def convert_value(self, opt, value): |
if value is not None: |
if self.nargs == 1: |
return self.check_value(opt, value) |
else: |
return tuple([self.check_value(opt, v) for v in value]) | |
def get_opt_string(self):
*no docstring available*
arguments:
return value:
<String>
source: compat/optparse.py
|
def get_opt_string(self): |
if self._long_opts: |
return self._long_opts[0] |
else: |
return self._short_opts[0] | |
def process(self, opt, value, values, parser):
*no docstring available*
arguments:
- self: <UNKNOWN>
- opt: <UNKNOWN>
- value: <UNKNOWN>
- values: <UNKNOWN>
- parser: <UNKNOWN>
return value:
<UNKNOWN>
source: compat/optparse.py
701 |
702 |
703 |
704 |
705 |
706 |
707 |
708 |
709 |
710 |
711 | |
def process(self, opt, value, values, parser): |
|
|
|
value = self.convert_value(opt, value) |
|
|
|
|
return self.take_action( |
self.action, self.dest, opt, value, values, parser) | |
def take_action(self, action, dest, opt, value, values, parser):
*no docstring available*
arguments:
- self: <UNKNOWN>
- action: <UNKNOWN>
- dest: <UNKNOWN>
- opt: <UNKNOWN>
- value: <UNKNOWN>
- values: <UNKNOWN>
- parser: <UNKNOWN>
return value:
<UNKNOWN>
source: compat/optparse.py
713 |
714 |
715 |
716 |
717 |
718 |
719 |
720 |
721 |
722 |
723 |
724 |
725 |
726 |
727 |
728 |
729 |
730 |
731 |
732 |
733 |
734 |
735 |
736 |
737 |
738 |
739 | |
def take_action(self, action, dest, opt, value, values, parser): |
if action == "store": |
setattr(values, dest, value) |
elif action == "store_const": |
setattr(values, dest, self.const) |
elif action == "store_true": |
setattr(values, dest, True) |
elif action == "store_false": |
setattr(values, dest, False) |
elif action == "append": |
values.ensure_value(dest, []).append(value) |
elif action == "count": |
setattr(values, dest, values.ensure_value(dest, 0) + 1) |
elif action == "callback": |
args = self.callback_args or () |
kwargs = self.callback_kwargs or {} |
self.callback(self, opt, value, parser, *args, **kwargs) |
elif action == "help": |
parser.print_help() |
parser.exit() |
elif action == "version": |
parser.print_version() |
parser.exit() |
else: |
raise RuntimeError, "unknown action %r" % self.action |
|
return 1 | |
def takes_value(self):
*no docstring available*
arguments:
return value:
<UNKNOWN>
def _repr(self):
*no docstring available*
arguments:
return value:
<UNKNOWN>
def __str__(self):
*no docstring available*
arguments:
return value:
<UNKNOWN>