Merge pull request #256 from yarda/functions-fix-max-args
builtin_functions: fixed check for number of arguments
This commit is contained in:
commit
15a34ee68d
8 changed files with 13 additions and 13 deletions
|
|
@ -24,7 +24,7 @@ class Function(object):
|
|||
if args is None or nargs_max is None:
|
||||
return False
|
||||
la = len(args)
|
||||
return (nargs_max == 0 or nargs_max == la) and (nargs_min is None or nargs_min <= la)
|
||||
return (nargs_max == 0 or nargs_max >= la) and (nargs_min is None or nargs_min <= la)
|
||||
|
||||
def execute(self, args):
|
||||
if self._check_args(args, self._nargs_max, self._nargs_min):
|
||||
|
|
|
|||
|
|
@ -13,8 +13,8 @@ class assertion(base.Function):
|
|||
exception will abort profile loading.
|
||||
"""
|
||||
def __init__(self):
|
||||
# 2 arguments
|
||||
super(assertion, self).__init__("assertion", 3)
|
||||
# 3 arguments
|
||||
super(assertion, self).__init__("assertion", 3, 3)
|
||||
|
||||
def execute(self, args):
|
||||
if not super(assertion, self).execute(args):
|
||||
|
|
|
|||
|
|
@ -13,8 +13,8 @@ class assertion_non_equal(base.Function):
|
|||
exception will abort profile loading.
|
||||
"""
|
||||
def __init__(self):
|
||||
# 2 arguments
|
||||
super(assertion_non_equal, self).__init__("assertion_non_equal", 3)
|
||||
# 3 arguments
|
||||
super(assertion_non_equal, self).__init__("assertion_non_equal", 3, 3)
|
||||
|
||||
def execute(self, args):
|
||||
if not super(assertion_non_equal, self).execute(args):
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@ class hex2cpulist(base.Function):
|
|||
Conversion function: converts hexadecimal CPU mask to CPU list
|
||||
"""
|
||||
def __init__(self):
|
||||
# one argument
|
||||
super(hex2cpulist, self).__init__("hex2cpulist", 1)
|
||||
# 1 argument
|
||||
super(hex2cpulist, self).__init__("hex2cpulist", 1, 1)
|
||||
|
||||
def execute(self, args):
|
||||
if not super(hex2cpulist, self).execute(args):
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@ class kb2s(base.Function):
|
|||
Conversion function: kbytes to sectors
|
||||
"""
|
||||
def __init__(self):
|
||||
# one argument
|
||||
super(kb2s, self).__init__("kb2s", 1)
|
||||
# 1 argument
|
||||
super(kb2s, self).__init__("kb2s", 1, 1)
|
||||
|
||||
def execute(self, args):
|
||||
if not super(kb2s, self).execute(args):
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ class regex_search_ternary(base.Function):
|
|||
"""
|
||||
def __init__(self):
|
||||
# 4 arguments
|
||||
super(regex_search_ternary, self).__init__("regex_search_ternary", 4)
|
||||
super(regex_search_ternary, self).__init__("regex_search_ternary", 4, 4)
|
||||
|
||||
def execute(self, args):
|
||||
if not super(regex_search_ternary, self).execute(args):
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@ class s2kb(base.Function):
|
|||
Conversion function: sectors to kbytes
|
||||
"""
|
||||
def __init__(self):
|
||||
# one argument
|
||||
super(s2kb, self).__init__("s2kb", 1)
|
||||
# 1 argument
|
||||
super(s2kb, self).__init__("s2kb", 1, 1)
|
||||
|
||||
def execute(self, args):
|
||||
if not super(s2kb, self).execute(args):
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ class virt_check(base.Function):
|
|||
"""
|
||||
def __init__(self):
|
||||
# 2 arguments
|
||||
super(virt_check, self).__init__("virt_check", 2)
|
||||
super(virt_check, self).__init__("virt_check", 2, 2)
|
||||
|
||||
def execute(self, args):
|
||||
if not super(virt_check, self).execute(args):
|
||||
|
|
|
|||
Loading…
Reference in a new issue