From 8f86e67c44a3e0c7adee3fcfa55a29706b426525 Mon Sep 17 00:00:00 2001 From: lmbelo Date: Wed, 6 Sep 2023 16:06:49 -0300 Subject: [PATCH] Code clean-up --- delphivcl/__init__.py | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/delphivcl/__init__.py b/delphivcl/__init__.py index 6bd558a..6a69104 100644 --- a/delphivcl/__init__.py +++ b/delphivcl/__init__.py @@ -1,10 +1,7 @@ import sys import os -import sys import platform import importlib -import importlib.machinery -import importlib.util def find_extension_module(): @@ -23,22 +20,23 @@ def find_extension_module(): # Win x86 lib_dir = "Win32" - if lib_dir: - lib_dir = os.path.join(os.path.dirname( - os.path.abspath(__file__)), lib_dir) - if not os.path.exists(lib_dir): - raise ValueError( - "DelphiVCL module not found. \ - Try to reinstall the delphivcl package or check for support compatibility.") - - for file_name in os.listdir(lib_dir): - if 'DelphiVCL' in file_name: - return os.path.join(lib_dir, os.path.basename(file_name)) - raise ValueError( - "DelphiVCL module not found. Try to reinstall the delphivcl package.") - else: + if not lib_dir: raise ValueError("Unsupported platform.") + lib_dir = os.path.join(os.path.dirname( + os.path.abspath(__file__)), lib_dir) + if not os.path.exists(lib_dir): + raise ValueError( + "DelphiVCL module not found. \ + Try to reinstall the delphivcl package or check for support compatibility.") + + for file_name in os.listdir(lib_dir): + if 'DelphiVCL' in file_name: + return os.path.join(lib_dir, os.path.basename(file_name)) + + raise ValueError( + "DelphiVCL module not found. Try to reinstall the delphivcl package.") + def new_import(): lib_path = find_extension_module()