From f9d42082a23f74af31929c970f7a25b443104439 Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Tue, 8 Apr 2025 15:23:44 +0200 Subject: [PATCH] Clean up importlib imports --- RNS/Cryptography/Hashes.py | 2 +- RNS/Cryptography/Provider.py | 2 +- RNS/Interfaces/AX25KISSInterface.py | 2 +- RNS/Interfaces/Android/KISSInterface.py | 2 +- RNS/Interfaces/Android/RNodeInterface.py | 2 +- RNS/Interfaces/Android/SerialInterface.py | 2 +- RNS/Interfaces/KISSInterface.py | 2 +- RNS/Interfaces/RNodeInterface.py | 4 ++-- RNS/Interfaces/RNodeMultiInterface.py | 4 ++-- RNS/Interfaces/SerialInterface.py | 2 +- RNS/Reticulum.py | 2 +- RNS/__init__.py | 2 +- 12 files changed, 14 insertions(+), 14 deletions(-) diff --git a/RNS/Cryptography/Hashes.py b/RNS/Cryptography/Hashes.py index fa6d488..595718b 100644 --- a/RNS/Cryptography/Hashes.py +++ b/RNS/Cryptography/Hashes.py @@ -20,7 +20,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -import importlib +import importlib.util if importlib.util.find_spec('hashlib') != None: import hashlib else: diff --git a/RNS/Cryptography/Provider.py b/RNS/Cryptography/Provider.py index 012d063..5c2b82a 100644 --- a/RNS/Cryptography/Provider.py +++ b/RNS/Cryptography/Provider.py @@ -20,7 +20,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -import importlib +import importlib.util PROVIDER_NONE = 0x00 PROVIDER_INTERNAL = 0x01 diff --git a/RNS/Interfaces/AX25KISSInterface.py b/RNS/Interfaces/AX25KISSInterface.py index bd6640d..2df42ba 100644 --- a/RNS/Interfaces/AX25KISSInterface.py +++ b/RNS/Interfaces/AX25KISSInterface.py @@ -70,7 +70,7 @@ class AX25KISSInterface(Interface): serial = None def __init__(self, owner, configuration): - import importlib + import importlib.util if importlib.util.find_spec('serial') != None: import serial else: diff --git a/RNS/Interfaces/Android/KISSInterface.py b/RNS/Interfaces/Android/KISSInterface.py index 92c3977..c4d33a0 100644 --- a/RNS/Interfaces/Android/KISSInterface.py +++ b/RNS/Interfaces/Android/KISSInterface.py @@ -63,7 +63,7 @@ class KISSInterface(Interface): serial = None def __init__(self, owner, configuration): - import importlib + import importlib.util if RNS.vendor.platformutils.is_android(): self.on_android = True if importlib.util.find_spec('usbserial4a') != None: diff --git a/RNS/Interfaces/Android/RNodeInterface.py b/RNS/Interfaces/Android/RNodeInterface.py index 316a106..62fab51 100644 --- a/RNS/Interfaces/Android/RNodeInterface.py +++ b/RNS/Interfaces/Android/RNodeInterface.py @@ -368,7 +368,7 @@ class RNodeInterface(Interface): lt_alock = float(c["airtime_limit_long"]) if "airtime_limit_long" in c and c["airtime_limit_long"] != None else None port = c["port"] if "port" in c else None - import importlib + import importlib.util if RNS.vendor.platformutils.is_android(): self.on_android = True if importlib.util.find_spec('usbserial4a') != None: diff --git a/RNS/Interfaces/Android/SerialInterface.py b/RNS/Interfaces/Android/SerialInterface.py index 0e45e40..41b6276 100644 --- a/RNS/Interfaces/Android/SerialInterface.py +++ b/RNS/Interfaces/Android/SerialInterface.py @@ -53,7 +53,7 @@ class SerialInterface(Interface): serial = None def __init__(self, owner, configuration): - import importlib + import importlib.util if RNS.vendor.platformutils.is_android(): self.on_android = True if importlib.util.find_spec('usbserial4a') != None: diff --git a/RNS/Interfaces/KISSInterface.py b/RNS/Interfaces/KISSInterface.py index 24b17ae..3a0c3eb 100644 --- a/RNS/Interfaces/KISSInterface.py +++ b/RNS/Interfaces/KISSInterface.py @@ -63,7 +63,7 @@ class KISSInterface(Interface): serial = None def __init__(self, owner, configuration): - import importlib + import importlib.util if importlib.util.find_spec('serial') != None: import serial else: diff --git a/RNS/Interfaces/RNodeInterface.py b/RNS/Interfaces/RNodeInterface.py index 69cbd3b..385d084 100644 --- a/RNS/Interfaces/RNodeInterface.py +++ b/RNS/Interfaces/RNodeInterface.py @@ -126,7 +126,7 @@ class RNodeInterface(Interface): if RNS.vendor.platformutils.is_android(): raise SystemError("Invalid interface type. The Android-specific RNode interface must be used on Android") - import importlib + import importlib.util if importlib.util.find_spec('serial') != None: import serial else: @@ -1190,7 +1190,7 @@ class BLEConnection(): self.connect_job_running = False self.device_disappeared = False - import importlib + import importlib.util if BLEConnection.bleak == None: if importlib.util.find_spec("bleak") != None: import bleak diff --git a/RNS/Interfaces/RNodeMultiInterface.py b/RNS/Interfaces/RNodeMultiInterface.py index 93f640f..21477f6 100644 --- a/RNS/Interfaces/RNodeMultiInterface.py +++ b/RNS/Interfaces/RNodeMultiInterface.py @@ -141,7 +141,7 @@ class RNodeMultiInterface(Interface): if RNS.vendor.platformutils.is_android(): raise SystemError("Invalid interface type. The Android-specific RNode interface must be used on Android") - import importlib + import importlib.util if importlib.util.find_spec('serial') != None: import serial else: @@ -927,7 +927,7 @@ class RNodeSubInterface(Interface): if RNS.vendor.platformutils.is_android(): raise SystemError("Invalid interface type. The Android-specific RNode interface must be used on Android") - import importlib + import importlib.util if importlib.util.find_spec('serial') != None: import serial else: diff --git a/RNS/Interfaces/SerialInterface.py b/RNS/Interfaces/SerialInterface.py index c216b15..4a68971 100755 --- a/RNS/Interfaces/SerialInterface.py +++ b/RNS/Interfaces/SerialInterface.py @@ -53,7 +53,7 @@ class SerialInterface(Interface): serial = None def __init__(self, owner, configuration): - import importlib + import importlib.util if importlib.util.find_spec('serial') != None: import serial else: diff --git a/RNS/Reticulum.py b/RNS/Reticulum.py index c606afd..a3ede88 100755 --- a/RNS/Reticulum.py +++ b/RNS/Reticulum.py @@ -39,7 +39,7 @@ else: from RNS.vendor.configobj import ConfigObj import configparser import multiprocessing.connection -import importlib +import importlib.util import threading import signal import atexit diff --git a/RNS/__init__.py b/RNS/__init__.py index 44c7d8b..b38faf5 100755 --- a/RNS/__init__.py +++ b/RNS/__init__.py @@ -49,7 +49,7 @@ pyc_modules = glob.glob(os.path.dirname(__file__)+"/*.pyc") modules = py_modules+pyc_modules __all__ = list(set([os.path.basename(f).replace(".pyc", "").replace(".py", "") for f in modules if not (f.endswith("__init__.py") or f.endswith("__init__.pyc"))])) -import importlib +import importlib.util if importlib.util.find_spec("cython"): import cython; compiled = cython.compiled else: compiled = False