From 40af7774ffa0aadb7d6a7aecea37d388336f48b9 Mon Sep 17 00:00:00 2001 From: Azalea Gui <22280294+hykilpikonna@users.noreply.github.com> Date: Mon, 7 Oct 2024 16:52:25 -0400 Subject: [PATCH] [O] Better formatting --- scripts/bin/tmux-tool.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/scripts/bin/tmux-tool.py b/scripts/bin/tmux-tool.py index 285d2fc..060ba96 100755 --- a/scripts/bin/tmux-tool.py +++ b/scripts/bin/tmux-tool.py @@ -80,12 +80,17 @@ def get_hardware_info(cpu=False, gpu=False): gpu_str = re.sub(r'lite hash rate', 'LHR', gpu_str, flags=re.IGNORECASE) # Remove manufacturer keywords - kw = ['Intel', 'AMD', 'NVIDIA', 'GeForce', 'Radeon', 'Core', '(R)', 'Series', 'Processor', 'Graphics', 'GPU', 'CPU'] - for k in kw: - cpu_str = cpu_str.replace(k, '') - gpu_str = gpu_str.replace(k, '') + kw = ['Intel', 'AMD', 'NVIDIA', 'GeForce', 'Radeon', '(R)', 'Series', 'Processor', 'Graphics', 'GPU', 'CPU', ',', 'Inc', '.', 'Family'] + def norm(str) -> str: + for k in kw: + str = str.replace(k, '') + while ' ' in str: + str = str.replace(' ', ' ') + # Remove repeated words + str = ' '.join(dict.fromkeys(str.split())) + return str.strip() - return " ".join(v for v in [cpu_str.strip(), gpu_str.strip()] if v) + return " ".join(v for v in [norm(cpu_str), norm(gpu_str)] if v) except Exception as e: return "Unable to fetch hardware info"