X-Git-Url: https://git.ayoreis.com/Adafruit_Blinka-hackapet.git/blobdiff_plain/a42332d0d0261bb5cc62365648eb11a6169b4bdf..refs/heads/micropython-pyi:/src/adafruit_blinka/__init__.py diff --git a/src/adafruit_blinka/__init__.py b/src/adafruit_blinka/__init__.py index 8c83305..5bdb2a5 100755 --- a/src/adafruit_blinka/__init__.py +++ b/src/adafruit_blinka/__init__.py @@ -1,10 +1,18 @@ -"""Module providing runtime utility objects to support the Micro/CircuitPython api""" +# SPDX-FileCopyrightText: 2021 Melissa LeBlanc-Williams for Adafruit Industries +# +# SPDX-License-Identifier: MIT +""" +`adafruit_blinka` - Runtime utility objects for re-implementation of CircuitPython API +====================================================================================== +* Author(s): cefn +""" -class Enum(object): + +class Enum: """ - Object supporting CircuitPython-style of static symbols - as seen with Direction.OUTPUT, Pull.UP + Object supporting CircuitPython-style of static symbols + as seen with Direction.OUTPUT, Pull.UP """ def __repr__(self): @@ -22,8 +30,8 @@ class Enum(object): @classmethod def iteritems(cls): """ - Inspects attributes of the class for instances of the class - and returns as key,value pairs mirroring dict#iteritems + Inspects attributes of the class for instances of the class + and returns as key,value pairs mirroring dict#iteritems """ for key in dir(cls): val = getattr(cls, key) @@ -33,19 +41,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): @@ -62,8 +75,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