Skip to content

Commit 5e59f4a

Browse files
committed
lora: Fix import error detection for missing drivers.
Signed-off-by: Breno RdV <breno@raccoon.ninja>
1 parent a7c805c commit 5e59f4a

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

micropython/lora/lora/lora/__init__.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,36 @@
55

66
ok = False # Flag if at least one modem driver package is installed
77

8+
9+
def _can_ignore_error(e):
10+
"""Check if ImportError can be ignored due to missing module."""
11+
return all(x in str(e) for x in ["no module named", "lora"])
12+
13+
814
# Various lora "sub-packages"
915

1016
try:
1117
from .sx126x import * # noqa: F401
1218

1319
ok = True
1420
except ImportError as e:
15-
if "no module named 'lora." not in str(e):
21+
if not _can_ignore_error(e):
1622
raise
1723

1824
try:
1925
from .sx127x import * # noqa: F401
2026

2127
ok = True
2228
except ImportError as e:
23-
if "no module named 'lora." not in str(e):
29+
if not _can_ignore_error(e):
2430
raise
2531

2632
try:
2733
from .stm32wl5 import * # noqa: F401
2834

2935
ok = True
3036
except ImportError as e:
31-
if "no module named 'lora." not in str(e):
37+
if not _can_ignore_error(e):
3238
raise
3339

3440

0 commit comments

Comments
 (0)