Skip to content

Commit

Permalink
Code clean-up
Browse files Browse the repository at this point in the history
  • Loading branch information
lmbelo committed Sep 6, 2023
1 parent 29f6d8d commit 8f86e67
Showing 1 changed file with 15 additions and 17 deletions.
32 changes: 15 additions & 17 deletions delphivcl/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import sys
import os
import sys
import platform
import importlib
import importlib.machinery
import importlib.util


def find_extension_module():
Expand All @@ -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()
Expand Down

0 comments on commit 8f86e67

Please sign in to comment.