From c032a2e438071b74530a3daa7053e99ca846c32f Mon Sep 17 00:00:00 2001 From: nothingbutlucas <69118979+nothingbutlucas@users.noreply.github.com> Date: Wed, 24 Apr 2024 12:11:43 -0300 Subject: [PATCH] refactor(if/elif): Add elif's on if "questions" The variable sorting can have only 1 value at a time. So does not make sense to ask on every if statement the value of sorting. If one statement is True, then, the other would be False. Signed-off-by: nothingbutlucas <69118979+nothingbutlucas@users.noreply.github.com> --- RNS/Utilities/rnstatus.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/RNS/Utilities/rnstatus.py b/RNS/Utilities/rnstatus.py index de41158..b3876ef 100644 --- a/RNS/Utilities/rnstatus.py +++ b/RNS/Utilities/rnstatus.py @@ -80,19 +80,19 @@ def program_setup(configdir, dispall=False, verbosity=0, name_filter=None, json= sorting = sorting.lower() if sorting == "rate" or sorting == "bitrate": interfaces.sort(key=lambda i: i["bitrate"], reverse=not sort_reverse) - if sorting == "rx": + elif sorting == "rx": interfaces.sort(key=lambda i: i["rxb"], reverse=not sort_reverse) - if sorting == "tx": + elif sorting == "tx": interfaces.sort(key=lambda i: i["txb"], reverse=not sort_reverse) - if sorting == "traffic": + elif sorting == "traffic": interfaces.sort(key=lambda i: i["rxb"]+i["txb"], reverse=not sort_reverse) - if sorting == "announces" or sorting == "announce": + elif sorting == "announces" or sorting == "announce": interfaces.sort(key=lambda i: i["incoming_announce_frequency"]+i["outgoing_announce_frequency"], reverse=not sort_reverse) - if sorting == "arx": + elif sorting == "arx": interfaces.sort(key=lambda i: i["incoming_announce_frequency"], reverse=not sort_reverse) - if sorting == "atx": + elif sorting == "atx": interfaces.sort(key=lambda i: i["outgoing_announce_frequency"], reverse=not sort_reverse) - if sorting == "held": + elif sorting == "held": interfaces.sort(key=lambda i: i["held_announces"], reverse=not sort_reverse) for ifstat in interfaces: