]> Repositories - Adafruit_Blinka-hackapet.git/blobdiff - src/adafruit_blinka/__init__.py
Merge pull request #1005 from makermelissa/libgpiod-fix
[Adafruit_Blinka-hackapet.git] / src / adafruit_blinka / __init__.py
index e3cc50c69a8570bae983c043283c58aa048a7edb..3624475b9bea4362504d4822f285fde296536128 100755 (executable)
 
 import os
 
-try:
-    import tomllib
-except ImportError:
-    import toml as tomllib
-
 
 class Enum:
     """
@@ -81,10 +76,17 @@ class Lockable(ContextManaged):
             self._locked = False
 
 
-def load_settings_toml(*, return_toml=False):
-    """Load values from settings.toml into os.environ, so that os.getenv returns them."""
+def load_settings_toml():
+    """Load values from settings.toml into os.environ, so that os.getenv returns them.
+    Note: This does not work in MicroPython because of the tomllib module not being available.
+    """
+    try:
+        import tomllib
+    except ImportError:
+        import toml as tomllib
+
     if not os.path.isfile("settings.toml"):
-        raise FileNotFoundError("settings.toml not cound in current directory.")
+        raise FileNotFoundError("settings.toml not found in current directory.")
 
     print("settings.toml found. Updating environment variables:")
     with open("settings.toml", "rb") as toml_file:
@@ -111,9 +113,7 @@ def load_settings_toml(*, return_toml=False):
         os.environ[key] = str(value)
         print(f" - {key} added")
 
-    if return_toml:
-        return settings
-    return None
+    return settings
 
 
 def patch_system():