Skip to content

Commit 2ad75e1

Browse files
committed
functions: Derive function name from module name
Prevents redundancy. The same thing is already done for plugins.
1 parent f27a290 commit 2ad75e1

26 files changed

+31
-28
lines changed

tuned/profiles/functions/base.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,15 @@ class Function(object):
88
"""
99
Built-in function
1010
"""
11-
def __init__(self, name, nargs_max, nargs_min = None):
12-
self._name = name
11+
def __init__(self, nargs_max, nargs_min = None):
1312
self._nargs_max = nargs_max
1413
self._nargs_min = nargs_min
1514
self._cmd = commands()
1615

16+
@property
17+
def name(self):
18+
return self.__class__.__module__.split(".")[-1].split("_", 1)[1]
19+
1720
# checks arguments
1821
# nargs_max - maximal number of arguments, there mustn't be more arguments,
1922
# if nargs_max is 0, number of arguments is unlimited
@@ -30,5 +33,5 @@ def execute(self, args):
3033
if self._check_args(args, self._nargs_max, self._nargs_min):
3134
return True
3235
else:
33-
log.error("invalid number of arguments for builtin function '%s'" % self._name)
36+
log.error("invalid number of arguments for builtin function '%s'" % self.name)
3437
return False

tuned/profiles/functions/function_assertion.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class Assertion(base.Function):
2020
"""
2121
def __init__(self):
2222
# 3 arguments
23-
super(Assertion, self).__init__("assertion", 3, 3)
23+
super(Assertion, self).__init__(3, 3)
2424

2525
def execute(self, args):
2626
if not super(Assertion, self).execute(args):

tuned/profiles/functions/function_assertion_non_equal.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class AssertionNonEqual(base.Function):
1919
"""
2020
def __init__(self):
2121
# 3 arguments
22-
super(AssertionNonEqual, self).__init__("assertion_non_equal", 3, 3)
22+
super(AssertionNonEqual, self).__init__(3, 3)
2323

2424
def execute(self, args):
2525
if not super(AssertionNonEqual, self).execute(args):

tuned/profiles/functions/function_calc_isolated_cores.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class CalcIsolatedCores(base.Function):
2121
"""
2222
def __init__(self):
2323
# max 1 argument
24-
super(CalcIsolatedCores, self).__init__("calc_isolated_cores", 1)
24+
super(CalcIsolatedCores, self).__init__(1)
2525

2626
def execute(self, args):
2727
if not super(CalcIsolatedCores, self).execute(args):

tuned/profiles/functions/function_check_net_queue_count.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class CheckNetQueueCount(base.Function):
1010
"""
1111
def __init__(self):
1212
# 1 argument
13-
super(CheckNetQueueCount, self).__init__("check_net_queue_count", 1, 1)
13+
super(CheckNetQueueCount, self).__init__(1, 1)
1414

1515
def execute(self, args):
1616
if not super(CheckNetQueueCount, self).execute(args):

tuned/profiles/functions/function_cpuinfo_check.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class CPUInfoCheck(base.Function):
1717
"""
1818
def __init__(self):
1919
# unlimited number of arguments, min 2 arguments
20-
super(CPUInfoCheck, self).__init__("cpuinfo_check", 0, 2)
20+
super(CPUInfoCheck, self).__init__(0, 2)
2121

2222
def execute(self, args):
2323
if not super(CPUInfoCheck, self).execute(args):

tuned/profiles/functions/function_cpulist2devs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class CPUList2Devs(base.Function):
1313
"""
1414
def __init__(self):
1515
# arbitrary number of arguments
16-
super(CPUList2Devs, self).__init__("cpulist2devs", 0)
16+
super(CPUList2Devs, self).__init__(0)
1717

1818
def execute(self, args):
1919
if not super(CPUList2Devs, self).execute(args):

tuned/profiles/functions/function_cpulist2hex.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class CPUList2Hex(base.Function):
1313
"""
1414
def __init__(self):
1515
# arbitrary number of arguments
16-
super(CPUList2Hex, self).__init__("cpulist2hex", 0)
16+
super(CPUList2Hex, self).__init__(0)
1717

1818
def execute(self, args):
1919
if not super(CPUList2Hex, self).execute(args):

tuned/profiles/functions/function_cpulist2hex_invert.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class CPUList2HexInvert(base.Function):
1414
"""
1515
def __init__(self):
1616
# arbitrary number of arguments
17-
super(CPUList2HexInvert, self).__init__("cpulist2hex_invert", 0)
17+
super(CPUList2HexInvert, self).__init__(0)
1818

1919
def execute(self, args):
2020
if not super(CPUList2HexInvert, self).execute(args):

tuned/profiles/functions/function_cpulist_invert.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class CPUListInvert(base.Function):
1414
"""
1515
def __init__(self):
1616
# arbitrary number of arguments
17-
super(CPUListInvert, self).__init__("cpulist_invert", 0)
17+
super(CPUListInvert, self).__init__(0)
1818

1919
def execute(self, args):
2020
if not super(CPUListInvert, self).execute(args):

0 commit comments

Comments
 (0)