From e9c1a52116bcdc1278425f08a3953bbcb96cb94e Mon Sep 17 00:00:00 2001 From: BYolivia Date: Sat, 29 Nov 2025 00:59:44 +0100 Subject: [PATCH] refactor platform detection logic and improve global variable handling --- logica/controlador.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/logica/controlador.py b/logica/controlador.py index 3f2ffb6..785650f 100644 --- a/logica/controlador.py +++ b/logica/controlador.py @@ -1,10 +1,13 @@ import platform -from contextlib import nullcontext -_OS = nullcontext + +_os = None def getPlataforma(): - if _OS== nullcontext: + global _os + if _os==None: + _os = _obtener_datos_sistema() + return _os def accion_placeholder(nombre_accion): @@ -24,10 +27,10 @@ def _obtener_datos_sistema(): tmpVar = platform.system().lower() if tmpVar.__contains__("windows"): print("Sistema operativo detectado: Windows") - return {"WINDOWS"} + return {'WINDOWS'} elif tmpVar.__contains__("darwin"): print("Sistema operativo detectado: MacOS") - return {"MACOS"} + return {'MACOS'} else: print("Sistema operativo detectado: Linux/Unix") - return {"LINUX"} \ No newline at end of file + return {'LINUX'} \ No newline at end of file