mirror of
https://github.com/ChuckBuilds/LEDMatrix.git
synced 2026-04-12 05:42:59 +00:00
fix dict class for web ui
This commit is contained in:
@@ -76,12 +76,23 @@ class DictWrapper:
|
|||||||
self._value = data
|
self._value = data
|
||||||
|
|
||||||
def __getattr__(self, name):
|
def __getattr__(self, name):
|
||||||
# Return None for missing attributes to avoid template errors
|
# Return a new DictWrapper with empty dict for missing attributes
|
||||||
return None
|
# This allows chaining like main_config.display.hardware.rows
|
||||||
|
return DictWrapper({})
|
||||||
|
|
||||||
def __getitem__(self, key):
|
def __getitem__(self, key):
|
||||||
# Support bracket notation as fallback
|
# Support bracket notation as fallback
|
||||||
return getattr(self, key, None)
|
return getattr(self, key, DictWrapper({}))
|
||||||
|
|
||||||
|
def items(self):
|
||||||
|
# Support .items() method for iteration
|
||||||
|
if hasattr(self, '_value'):
|
||||||
|
return {}
|
||||||
|
return {k: v for k, v in self.__dict__.items() if not k.startswith('_')}
|
||||||
|
|
||||||
|
def get(self, key, default=None):
|
||||||
|
# Support .get() method
|
||||||
|
return getattr(self, key, default)
|
||||||
|
|
||||||
class DisplayMonitor:
|
class DisplayMonitor:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user