Skip to content

Commit a4b9185

Browse files
committed
functions: Use CapWords for function classes
This is the standard in Python and it prevents the issue of using reserved/existing names, e.g., in the case of the `exec` or `log` function.
1 parent eb9bf22 commit a4b9185

25 files changed

+75
-75
lines changed

tuned/profiles/functions/function_assertion.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
log = tuned.logs.get()
88

9-
class assertion(base.Function):
9+
class Assertion(base.Function):
1010
"""
1111
Compares the second argument and the third argument.
1212
If they _do not match_, the function logs the text from
@@ -22,10 +22,10 @@ class assertion(base.Function):
2222
"""
2323
def __init__(self):
2424
# 3 arguments
25-
super(assertion, self).__init__("assertion", 3, 3)
25+
super(Assertion, self).__init__("assertion", 3, 3)
2626

2727
def execute(self, args):
28-
if not super(assertion, self).execute(args):
28+
if not super(Assertion, self).execute(args):
2929
return None
3030
if args[1] != args[2]:
3131
log.error("assertion '%s' failed: '%s' != '%s'" % (args[0], args[1], args[2]))

tuned/profiles/functions/function_assertion_non_equal.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
log = tuned.logs.get()
88

9-
class assertion_non_equal(base.Function):
9+
class AssertionNonEqual(base.Function):
1010
"""
1111
Compares the second argument and the third argument.
1212
If they _match_, the function logs the text from
@@ -21,10 +21,10 @@ class assertion_non_equal(base.Function):
2121
"""
2222
def __init__(self):
2323
# 3 arguments
24-
super(assertion_non_equal, self).__init__("assertion_non_equal", 3, 3)
24+
super(AssertionNonEqual, self).__init__("assertion_non_equal", 3, 3)
2525

2626
def execute(self, args):
27-
if not super(assertion_non_equal, self).execute(args):
27+
if not super(AssertionNonEqual, self).execute(args):
2828
return None
2929
if args[1] == args[2]:
3030
log.error("assertion '%s' failed: '%s' == '%s'" % (args[0], args[1], args[2]))

tuned/profiles/functions/function_calc_isolated_cores.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
log = tuned.logs.get()
88

9-
class calc_isolated_cores(base.Function):
9+
class CalcIsolatedCores(base.Function):
1010
"""
1111
Calculates and returns a list of isolated cores. The argument
1212
specifies how many cores per socket should be reserved for housekeeping.
@@ -21,10 +21,10 @@ class calc_isolated_cores(base.Function):
2121
"""
2222
def __init__(self):
2323
# max 1 argument
24-
super(calc_isolated_cores, self).__init__("calc_isolated_cores", 1)
24+
super(CalcIsolatedCores, self).__init__("calc_isolated_cores", 1)
2525

2626
def execute(self, args):
27-
if not super(calc_isolated_cores, self).execute(args):
27+
if not super(CalcIsolatedCores, self).execute(args):
2828
return None
2929
cpus_reserve = 1
3030
if len(args) > 0:

tuned/profiles/functions/function_check_net_queue_count.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@
33

44
log = tuned.logs.get()
55

6-
class check_net_queue_count(base.Function):
6+
class CheckNetQueueCount(base.Function):
77
"""
88
Checks whether the first argument is a valid queue count for net devices.
99
If yes, returns it, otherwise returns the number of housekeeping CPUs.
1010
"""
1111
def __init__(self):
1212
# 1 argument
13-
super(check_net_queue_count, self).__init__("check_net_queue_count", 1, 1)
13+
super(CheckNetQueueCount, self).__init__("check_net_queue_count", 1, 1)
1414

1515
def execute(self, args):
16-
if not super(check_net_queue_count, self).execute(args):
16+
if not super(CheckNetQueueCount, self).execute(args):
1717
return None
1818
if args[0].isdigit():
1919
return args[0]

tuned/profiles/functions/function_cpuinfo_check.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
log = tuned.logs.get()
66

7-
class cpuinfo_check(base.Function):
7+
class CPUInfoCheck(base.Function):
88
"""
99
Checks regexes against the content of `/proc/cpuinfo`.
1010
@@ -20,10 +20,10 @@ class cpuinfo_check(base.Function):
2020
"""
2121
def __init__(self):
2222
# unlimited number of arguments, min 2 arguments
23-
super(cpuinfo_check, self).__init__("cpuinfo_check", 0, 2)
23+
super(CPUInfoCheck, self).__init__("cpuinfo_check", 0, 2)
2424

2525
def execute(self, args):
26-
if not super(cpuinfo_check, self).execute(args):
26+
if not super(CPUInfoCheck, self).execute(args):
2727
return None
2828
cpuinfo = self._cmd.read_file("/proc/cpuinfo")
2929
for i in range(0, len(args), 2):

tuned/profiles/functions/function_cpulist2devs.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
log = tuned.logs.get()
55

6-
class cpulist2devs(base.Function):
6+
class CPUList2Devs(base.Function):
77
"""
88
Converts a CPU list into a comma-separated list of device names.
99
@@ -16,9 +16,9 @@ class cpulist2devs(base.Function):
1616
"""
1717
def __init__(self):
1818
# arbitrary number of arguments
19-
super(cpulist2devs, self).__init__("cpulist2devs", 0)
19+
super(CPUList2Devs, self).__init__("cpulist2devs", 0)
2020

2121
def execute(self, args):
22-
if not super(cpulist2devs, self).execute(args):
22+
if not super(CPUList2Devs, self).execute(args):
2323
return None
2424
return self._cmd.cpulist2string(self._cmd.cpulist_unpack(",".join(args)), prefix = "cpu")

tuned/profiles/functions/function_cpulist2hex.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
log = tuned.logs.get()
77

8-
class cpulist2hex(base.Function):
8+
class CPUList2Hex(base.Function):
99
"""
1010
Converts a CPU list into a hexadecimal CPU mask.
1111
@@ -18,9 +18,9 @@ class cpulist2hex(base.Function):
1818
"""
1919
def __init__(self):
2020
# arbitrary number of arguments
21-
super(cpulist2hex, self).__init__("cpulist2hex", 0)
21+
super(CPUList2Hex, self).__init__("cpulist2hex", 0)
2222

2323
def execute(self, args):
24-
if not super(cpulist2hex, self).execute(args):
24+
if not super(CPUList2Hex, self).execute(args):
2525
return None
2626
return self._cmd.cpulist2hex(",,".join(args))

tuned/profiles/functions/function_cpulist2hex_invert.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
log = tuned.logs.get()
77

8-
class cpulist2hex_invert(base.Function):
8+
class CPUList2HexInvert(base.Function):
99
"""
1010
Converts a CPU list into a hexadecimal CPU mask and inverts it.
1111
@@ -19,10 +19,10 @@ class cpulist2hex_invert(base.Function):
1919
"""
2020
def __init__(self):
2121
# arbitrary number of arguments
22-
super(cpulist2hex_invert, self).__init__("cpulist2hex_invert", 0)
22+
super(CPUList2HexInvert, self).__init__("cpulist2hex_invert", 0)
2323

2424
def execute(self, args):
25-
if not super(cpulist2hex_invert, self).execute(args):
25+
if not super(CPUList2HexInvert, self).execute(args):
2626
return None
2727
# current implementation inverts the CPU list and then converts it to hexmask
2828
return self._cmd.cpulist2hex(",".join(str(v) for v in self._cmd.cpulist_invert(",,".join(args))))

tuned/profiles/functions/function_cpulist_invert.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
log = tuned.logs.get()
77

8-
class cpulist_invert(base.Function):
8+
class CPUListInvert(base.Function):
99
"""
1010
Inverts a CPU list, i.e., returns its complement. The complement is
1111
computed from the list of online CPUs in `/sys/devices/system/cpu/online`.
@@ -19,9 +19,9 @@ class cpulist_invert(base.Function):
1919
"""
2020
def __init__(self):
2121
# arbitrary number of arguments
22-
super(cpulist_invert, self).__init__("cpulist_invert", 0)
22+
super(CPUListInvert, self).__init__("cpulist_invert", 0)
2323

2424
def execute(self, args):
25-
if not super(cpulist_invert, self).execute(args):
25+
if not super(CPUListInvert, self).execute(args):
2626
return None
2727
return ",".join(str(v) for v in self._cmd.cpulist_invert(",,".join(args)))

tuned/profiles/functions/function_cpulist_online.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
log = tuned.logs.get()
77

8-
class cpulist_online(base.Function):
8+
class CPUListOnline(base.Function):
99
"""
1010
Returns a CPU list containing the online CPUs from the given CPU list.
1111
@@ -19,10 +19,10 @@ class cpulist_online(base.Function):
1919
"""
2020
def __init__(self):
2121
# arbitrary number of arguments
22-
super(cpulist_online, self).__init__("cpulist_online", 0)
22+
super(CPUListOnline, self).__init__("cpulist_online", 0)
2323

2424
def execute(self, args):
25-
if not super(cpulist_online, self).execute(args):
25+
if not super(CPUListOnline, self).execute(args):
2626
return None
2727
cpus = self._cmd.cpulist_unpack(",".join(args))
2828
online = self._cmd.cpulist_unpack(self._cmd.read_file("/sys/devices/system/cpu/online"))

0 commit comments

Comments
 (0)