[PATCH] tuna: replace match with if statements

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The match-case keyword statements were introduced in Python 3.10. At the
time RHEL 9 and other older distributions only have Python 3.9. This patch
will make it easier for older distributions to use newer versions of
Tuna.

Signed-off-by: John B. Wyatt IV <jwyatt@xxxxxxxxxx>
---
 tuna/cpupower.py | 25 ++++++++++++-------------
 1 file changed, 12 insertions(+), 13 deletions(-)

diff --git a/tuna/cpupower.py b/tuna/cpupower.py
index ec04b90..ecb2507 100755
--- a/tuna/cpupower.py
+++ b/tuna/cpupower.py
@@ -38,20 +38,19 @@ if have_cpupower:
                 self.__cpu_list = utils.get_all_cpu_list()
 
         def handle_common_lcpw_errors(self, e, error_type, idle_name):
-            match e:
-                case 0:
-                    pass
-                case -1:
-                    print(f"Idlestate {idle_name} not available", file=sys.stderr)
-                case -2:
-                    print("Disabling is not supported by the kernel", file=sys.stderr)
-                case -3:
-                    if error_type == Cpupower.LCPW_ERROR_THREE_CASE:
-                        print("No write access to disable/enable C-states: try using sudo", file=sys.stderr)
-                    else:
-                        print(f"Not documented: {e}", file=sys.stderr)
-                case _:
+            if e == 0:
+                pass
+            elif e == -1:
+                print(f"Idlestate {idle_name} not available", file=sys.stderr)
+            elif e == -2:
+                print("Disabling is not supported by the kernel", file=sys.stderr)
+            elif e == -3:
+                if error_type == Cpupower.LCPW_ERROR_THREE_CASE:
+                    print("No write access to disable/enable C-states: try using sudo", file=sys.stderr)
+                else:
                     print(f"Not documented: {e}", file=sys.stderr)
+            else:
+                print(f"Not documented: {e}", file=sys.stderr)
 
         def get_idle_states(self, cpu):
             """
-- 
2.50.1





[Index of Archives]     [RT Stable]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux