]> Repositories - Adafruit_Blinka-hackapet.git/commitdiff
Change to using try/except blocks
authorMelissa LeBlanc-Williams <melissa@adafruit.com>
Thu, 6 May 2021 20:37:58 +0000 (13:37 -0700)
committerMelissa LeBlanc-Williams <melissa@adafruit.com>
Thu, 6 May 2021 20:37:58 +0000 (13:37 -0700)
src/board.py

index cb8c6c891d6257ccb8d30a939054579766ff27d3..1b42b53211399f7606e65571a2489d735d4f5cd7 100755 (executable)
@@ -224,15 +224,19 @@ elif "sphinx" in sys.modules:
 else:
     raise NotImplementedError("Board not supported {}".format(board_id))
 
-if SDA and SCL:
+try:
+    if SDA and SCL:
 
-    def I2C():
-        """The singleton I2C interface"""
-        return busio.I2C(SCL, SDA)
+        def I2C():
+            """The singleton I2C interface"""
+            return busio.I2C(SCL, SDA)
 
+    if SCLK:
 
-if SCLK:
+        def SPI():
+            """The singleton SPI interface"""
+            return busio.SPI(SCLK, MOSI, MISO)
 
-    def SPI():
-        """The singleton SPI interface"""
-        return busio.SPI(SCLK, MOSI, MISO)
+
+except NameError:
+    pass