From 34eab633ece0bc5e71c3890c962e1efedb5bf3cb Mon Sep 17 00:00:00 2001 From: caternuson Date: Thu, 18 Aug 2022 12:40:34 -0700 Subject: [PATCH 1/4] add path check for neopixel --- adafruit_seesaw/neopixel.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/adafruit_seesaw/neopixel.py b/adafruit_seesaw/neopixel.py index 79ab9ae..3023b48 100644 --- a/adafruit_seesaw/neopixel.py +++ b/adafruit_seesaw/neopixel.py @@ -18,6 +18,9 @@ def const(x): return x +### hack to make sure this module is not placed in root CIRCUITPY/lib folder +if __file__.split('/')[-2] != 'adafruit_seesaw': + raise ImportError("seesaw neopixel being imported from wrong location") __version__ = "0.0.0+auto.0" __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_seesaw.git" From f5bc2ee742b1e8915cbcc51c29db41456a65d020 Mon Sep 17 00:00:00 2001 From: caternuson Date: Thu, 18 Aug 2022 12:49:26 -0700 Subject: [PATCH 2/4] black --- adafruit_seesaw/neopixel.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/adafruit_seesaw/neopixel.py b/adafruit_seesaw/neopixel.py index 3023b48..7866844 100644 --- a/adafruit_seesaw/neopixel.py +++ b/adafruit_seesaw/neopixel.py @@ -18,8 +18,9 @@ def const(x): return x + ### hack to make sure this module is not placed in root CIRCUITPY/lib folder -if __file__.split('/')[-2] != 'adafruit_seesaw': +if __file__.split("/")[-2] != "adafruit_seesaw": raise ImportError("seesaw neopixel being imported from wrong location") __version__ = "0.0.0+auto.0" From 56e6cec7a9526a4f9918a2650dd04cc371e417b3 Mon Sep 17 00:00:00 2001 From: caternuson Date: Thu, 18 Aug 2022 13:45:04 -0700 Subject: [PATCH 3/4] change conditional --- adafruit_seesaw/neopixel.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adafruit_seesaw/neopixel.py b/adafruit_seesaw/neopixel.py index 7866844..813f044 100644 --- a/adafruit_seesaw/neopixel.py +++ b/adafruit_seesaw/neopixel.py @@ -20,7 +20,7 @@ def const(x): ### hack to make sure this module is not placed in root CIRCUITPY/lib folder -if __file__.split("/")[-2] != "adafruit_seesaw": +if "." not in __name__: raise ImportError("seesaw neopixel being imported from wrong location") __version__ = "0.0.0+auto.0" From 1dc8fcacfb390b45ae1344e15181abb913cf5cc4 Mon Sep 17 00:00:00 2001 From: caternuson Date: Mon, 22 Aug 2022 10:12:19 -0700 Subject: [PATCH 4/4] update message --- adafruit_seesaw/neopixel.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/adafruit_seesaw/neopixel.py b/adafruit_seesaw/neopixel.py index 813f044..8f95fb4 100644 --- a/adafruit_seesaw/neopixel.py +++ b/adafruit_seesaw/neopixel.py @@ -21,7 +21,9 @@ def const(x): ### hack to make sure this module is not placed in root CIRCUITPY/lib folder if "." not in __name__: - raise ImportError("seesaw neopixel being imported from wrong location") + raise ImportError( + "seesaw neopixel being imported from unexpected location - is seesaw neopixel use intended?" + ) __version__ = "0.0.0+auto.0" __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_seesaw.git"