Skip to content

Commit

Permalink
fix missing __enter__ and __exit__
Browse files Browse the repository at this point in the history
  • Loading branch information
Mickael committed Oct 1, 2020
1 parent acbc2b7 commit 35db3e0
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
11 changes: 11 additions & 0 deletions GreenPonik_Thermistor10k/Thermistor10k.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
EMAIL = "[email protected]"
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 = [
Expand Down
2 changes: 1 addition & 1 deletion version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.0.9"
__version__ = "0.0.10"

0 comments on commit 35db3e0

Please sign in to comment.