From 8df89cc2d0a396bd8127ec3ab13e98df42dc37f2 Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Mon, 2 Dec 2024 14:20:34 +0100 Subject: [PATCH] Allow dynamic sub-module import from compiled python bytecode --- RNS/Cryptography/__init__.py | 6 ++++-- RNS/Interfaces/Android/__init__.py | 6 ++++-- RNS/Interfaces/__init__.py | 6 ++++-- RNS/Reticulum.py | 3 ++- RNS/Utilities/__init__.py | 6 ++++-- RNS/__init__.py | 6 ++++-- RNS/vendor/__init__.py | 6 ++++-- 7 files changed, 26 insertions(+), 13 deletions(-) diff --git a/RNS/Cryptography/__init__.py b/RNS/Cryptography/__init__.py index eb2934e..0ac0207 100644 --- a/RNS/Cryptography/__init__.py +++ b/RNS/Cryptography/__init__.py @@ -20,5 +20,7 @@ elif cp.PROVIDER == cp.PROVIDER_PYCA: from RNS.Cryptography.Proxies import Ed25519PrivateKeyProxy as Ed25519PrivateKey from RNS.Cryptography.Proxies import Ed25519PublicKeyProxy as Ed25519PublicKey -modules = glob.glob(os.path.dirname(__file__)+"/*.py") -__all__ = [ os.path.basename(f)[:-3] for f in modules if not f.endswith('__init__.py')] +py_modules = glob.glob(os.path.dirname(__file__)+"/*.py") +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"))])) \ No newline at end of file diff --git a/RNS/Interfaces/Android/__init__.py b/RNS/Interfaces/Android/__init__.py index ba9eae1..299b693 100644 --- a/RNS/Interfaces/Android/__init__.py +++ b/RNS/Interfaces/Android/__init__.py @@ -23,5 +23,7 @@ import os import glob -modules = glob.glob(os.path.dirname(__file__)+"/*.py") -__all__ = [ os.path.basename(f)[:-3] for f in modules if not f.endswith('__init__.py')] \ No newline at end of file +py_modules = glob.glob(os.path.dirname(__file__)+"/*.py") +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"))])) \ No newline at end of file diff --git a/RNS/Interfaces/__init__.py b/RNS/Interfaces/__init__.py index 84fff6a..89c1f79 100755 --- a/RNS/Interfaces/__init__.py +++ b/RNS/Interfaces/__init__.py @@ -24,5 +24,7 @@ import os import glob import RNS.Interfaces.Android -modules = glob.glob(os.path.dirname(__file__)+"/*.py") -__all__ = [ os.path.basename(f)[:-3] for f in modules if not f.endswith('__init__.py')] +py_modules = glob.glob(os.path.dirname(__file__)+"/*.py") +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"))])) \ No newline at end of file diff --git a/RNS/Reticulum.py b/RNS/Reticulum.py index 1a36326..2882e87 100755 --- a/RNS/Reticulum.py +++ b/RNS/Reticulum.py @@ -283,7 +283,8 @@ class Reticulum: time.sleep(1.5) self.__apply_config() - RNS.log("Configuration loaded from "+self.configpath, RNS.LOG_VERBOSE) + RNS.log(f"Utilising cryptography backend \"{RNS.Cryptography.Provider.backend()}\"", RNS.LOG_VERBOSE) + RNS.log(f"Configuration loaded from {self.configpath}", RNS.LOG_VERBOSE) RNS.Identity.load_known_destinations() diff --git a/RNS/Utilities/__init__.py b/RNS/Utilities/__init__.py index be84862..299b693 100644 --- a/RNS/Utilities/__init__.py +++ b/RNS/Utilities/__init__.py @@ -23,5 +23,7 @@ import os import glob -modules = glob.glob(os.path.dirname(__file__)+"/*.py") -__all__ = [ os.path.basename(f)[:-3] for f in modules if not f.endswith('__init__.py')] +py_modules = glob.glob(os.path.dirname(__file__)+"/*.py") +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"))])) \ No newline at end of file diff --git a/RNS/__init__.py b/RNS/__init__.py index 8828e48..24e6b23 100755 --- a/RNS/__init__.py +++ b/RNS/__init__.py @@ -43,8 +43,10 @@ from .Resource import Resource, ResourceAdvertisement from .Cryptography import HKDF from .Cryptography import Hashes -modules = glob.glob(os.path.dirname(__file__)+"/*.py") -__all__ = [ os.path.basename(f)[:-3] for f in modules if not f.endswith('__init__.py')] +py_modules = glob.glob(os.path.dirname(__file__)+"/*.py") +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"))])) LOG_CRITICAL = 0 LOG_ERROR = 1 diff --git a/RNS/vendor/__init__.py b/RNS/vendor/__init__.py index e3164b0..ccfb449 100755 --- a/RNS/vendor/__init__.py +++ b/RNS/vendor/__init__.py @@ -1,5 +1,7 @@ import os import glob -modules = glob.glob(os.path.dirname(__file__)+"/*.py") -__all__ = [ os.path.basename(f)[:-3] for f in modules if not f.endswith('__init__.py')] +py_modules = glob.glob(os.path.dirname(__file__)+"/*.py") +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"))])) \ No newline at end of file