From 35db3e01353653d0686fce60c50d248f5582766d Mon Sep 17 00:00:00 2001 From: Mickael Date: Thu, 1 Oct 2020 18:57:23 +0200 Subject: [PATCH] fix missing __enter__ and __exit__ --- GreenPonik_Thermistor10k/Thermistor10k.py | 11 +++++++++++ setup.py | 2 +- version.py | 2 +- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/GreenPonik_Thermistor10k/Thermistor10k.py b/GreenPonik_Thermistor10k/Thermistor10k.py index bae0833..ab31de1 100644 --- a/GreenPonik_Thermistor10k/Thermistor10k.py +++ b/GreenPonik_Thermistor10k/Thermistor10k.py @@ -27,6 +27,17 @@ def __init__(self, bus=DEFAULT_BUS, addr=DEFAULT_ADDR): self._addr = addr self._debug = False + def __enter__(self): + """Context manager enter function.""" + # Just return this object so it can be used in a with statement, like + # with WaterPumpDriver(bus=1, addr=100) as driver: + # # do stuff! + return self + + def __exit__(self, exc_type, exc_val, exc_tb): + """Context manager exit function, ensures resources are cleaned up.""" + return False # Don't suppress exceptions. + @property def bus(self): return self._bus diff --git a/setup.py b/setup.py index e00c518..62e1a25 100644 --- a/setup.py +++ b/setup.py @@ -10,7 +10,7 @@ EMAIL = "contact@greenponik.com" AUTHOR = "GreenPonik SAS" REQUIRES_PYTHON = ">=3.6.0" -VERSION = "0.0.9" +VERSION = "0.0.10" # What packages are required for this module to be executed? REQUIRED = [ diff --git a/version.py b/version.py index 00ec2dc..9b36b86 100644 --- a/version.py +++ b/version.py @@ -1 +1 @@ -__version__ = "0.0.9" +__version__ = "0.0.10"