Files
2025-04-30 08:48:49 -05:00

34 lines
1.7 KiB
Python

# uncompyle6 version 3.9.2
# Python bytecode version base 3.7.0 (3394)
# Decompiled from: Python 3.8.19 (default, Mar 20 2024, 15:27:52)
# [Clang 14.0.6 ]
# Embedded file name: /var/user/app/device_supervisorbak/device_supervisor/lib/pycomm3/map.py
# Compiled at: 2024-04-18 03:12:57
# Size of source mod 2**32: 3457 bytes
__all__ = [
"EnumMap"]
class MapMeta(type):
def __new__Parse error at or near `LOAD_DICTCOMP' instruction at offset 40
def __getitem__(self, item):
val = self._members_.__getitem__(item.lower() if isinstance(item, str) else item)
if self._return_caps_only_:
if isinstance(val, str):
val = val.upper()
return val
def get(cls, item, default=None):
val = cls._members_.get(item.lower() if isinstance(item, str) else item, default)
if cls._return_caps_only_:
if isinstance(val, str):
val = val.upper()
return val
def __contains__(self, item):
return self._members_.__contains__(item.lower() if isinstance(item, str) else item)
class EnumMap(metaclass=MapMeta):
__doc__ = "\n A simple enum-like class that allows dict-like __getitem__() and get() lookups.\n __getitem__() and get() are case-insensitive and bidirectional\n\n example:\n\n class TestEnum(Pycomm3EnumMap):\n x = 100\n\n >>> TestEnum.x\n 100\n >>> TestEnum['X']\n 100\n >>> TestEnum[100]\n x\n\n Note: this class is really only to be used internally, it doesn't cover anything more than simple subclasses\n (as in attributes only, don't add methods except for classmethods)\n It's really just to provide dict-like item access with enum-like attributes.\n\n "