Skip to contentSkip to conversation

bindings: python: simplify environ access

PATCH Applied Phil Howard 2 participants 2 messages Oct 12, 2023 – Oct 13, 2023 GPIO

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bindings: python: simplify environ access

Use environ.get() in lieu of an explicit check for GPIOD_WITH_TESTS in os.environ.

Returns None and evaluates as False if GPIOD_WITH_TESTS == "1" is not specified.

---
 bindings/python/setup.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
bindings/python/setup.py +1 -1
index fd674aa..df10e18 100644
@@ -50,7 +50,7 @@ procname_ext = Extension(
 )
 
 extensions = [gpiod_ext]
-if "GPIOD_WITH_TESTS" in environ and environ["GPIOD_WITH_TESTS"] == "1":
+if environ.get("GPIOD_WITH_TESTS") == "1":
     extensions.append(gpiosim_ext)
     extensions.append(procname_ext)
 
Signature · 1 line
2.34.1
#1 lore raw
Quoted 26 lines · Phil Howard

Use environ.get() in lieu of an explicit check for GPIOD_WITH_TESTS in os.environ.

Returns None and evaluates as False if GPIOD_WITH_TESTS == "1" is not specified.

---
 bindings/python/setup.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
bindings/python/setup.py +1 -2
index fd674aa..df10e18 100644
@@ -50,7 +50,7 @@ procname_ext = Extension(
 )
 
 extensions = [gpiod_ext]
-if "GPIOD_WITH_TESTS" in environ and environ["GPIOD_WITH_TESTS"] == "1":
+if environ.get("GPIOD_WITH_TESTS") == "1":
     extensions.append(gpiosim_ext)
     extensions.append(procname_ext)
 
--
Quoted 2 lines

2.34.1

Applied, thanks!

Bart