]> Repositories - Adafruit_Blinka-hackapet.git/blob - python/mcp/__init__.py
File upload routine to complement https://github.com/ShrimpingIt/cockle/blob/1d593448...
[Adafruit_Blinka-hackapet.git] / python / mcp / __init__.py
1 class Enum(object):
2
3
4     @classmethod
5     def iteritems(cls):
6         for key in dir(cls):
7             val = getattr(cls, key)
8             if type(val) is cls:
9                 yield (key, val)
10
11
12     def __repr__(self):
13         """
14         Assumes instance will be found as attribute of own
15         class. Returns dot-subscripted path to instance
16         """
17         cls = type(self)
18         for key in dir(cls):
19             if getattr(cls, key) is self:
20                 return "{}.{}.{}".format(cls.__module__, cls.__qualname__, key)
21         return repr(self)