16 from java.lang
import Byte, Short, Integer, Long, Boolean, Float, Double
29 def coerce(self, arguments, named, dryrun=False):
31 arguments = [c.coerce(a, dryrun)
32 for c, a
in zip(self.
_coercers_coercers, arguments)]
34 arguments.append(
dict(named))
42 for position, types
in self.
_parse_types_parse_types(signatures)]
46 for sig
in signatures:
47 for index, arg
in enumerate(sig.args):
48 types.setdefault(index + 1, []).append(arg)
49 return sorted(types.items())
60 for coercer
in coercers:
61 if coercer.handles(type):
65 return not all(coercer
is first
for coercer
in rest)
88 def coerce(self, argument, dryrun=False):
93 return self.
_coerce_coerce(argument)
95 raise ValueError(
'Argument at position %d cannot be coerced to %s.'
99 raise NotImplementedError
114 _primitives = [
'boolean']
118 return {
'false':
False,
'true':
True}[argument.lower()]
131 _types = [Byte, Short, Integer, Long]
135 _primitives = [
'byte',
'short',
'int',
'long']
145 _name =
'floating point number'
149 _types = [Float, Double]
153 _primitives = [
'float',
'double']
156 return float(argument)
171 self.
_index_index = argspec.minargs
if argspec.varargs
else -1
175 arguments[self.
_index_index:] = [arguments[self.
_index_index:]]
182 return len(arguments) == self.
_index_index + 1
def _coerce(self, argument)
def _get_coercer(self, types, position)
def find_coercers(self, signatures)
def _parse_types(self, signatures)
def _coercers_conflict(self, first, *rest)
def _get_coercer_for_type(self, type, coercers)
def _coerce(self, argument)
def _coerce(self, argument)
def __init__(self, signatures, argspec)
def coerce(self, arguments, named, dryrun=False)
def _coerce(self, argument)
def handles(self, argument)
def _passing_list(self, arguments)
def handle(self, arguments)
def _correct_count(self, arguments)
def __init__(self, argspec)
def __init__(self, position=None)
def _coerce(self, argument)
def coerce(self, argument, dryrun=False)
def contains_var(string, identifiers='$@&')