X-Git-Url: https://git.ayoreis.com/hackapet/Adafruit_Blinka.git/blobdiff_plain/2ed6f5d2c74510c8be535c2218ba74ec05a1920d..de652f72b1884328ee22ec36deaa6320addd32e7:/src/adafruit_blinka/__init__.py diff --git a/src/adafruit_blinka/__init__.py b/src/adafruit_blinka/__init__.py index 845c802..2df8a2d 100755 --- a/src/adafruit_blinka/__init__.py +++ b/src/adafruit_blinka/__init__.py @@ -5,7 +5,8 @@ * Author(s): cefn """ -class Enum(object): + +class Enum: """ Object supporting CircuitPython-style of static symbols as seen with Direction.OUTPUT, Pull.UP @@ -37,19 +38,24 @@ class Enum(object): class ContextManaged: """An object that automatically deinitializes hardware with a context manager.""" + def __enter__(self): return self def __exit__(self, exc_type, exc_value, traceback): self.deinit() + # pylint: disable=no-self-use def deinit(self): """Free any hardware used by the object.""" - pass + return + + # pylint: enable=no-self-use class Lockable(ContextManaged): """An object that must be locked to prevent collisions on a microcontroller resource.""" + _locked = False def try_lock(self): @@ -66,8 +72,13 @@ class Lockable(ContextManaged): else: raise ValueError("Not locked") + def patch_system(): """Patch modules that may be different due to the platform.""" + # pylint: disable=import-outside-toplevel import sys from adafruit_blinka.agnostic import time - sys.modules['time'] = time + + # pylint: enable=import-outside-toplevel + + sys.modules["time"] = time