Changeset - 5b38db0369fc
[Not reviewed]
default
0 1 0
drewp@bigasterisk.com - 20 months ago 2023-05-22 08:06:27
drewp@bigasterisk.com
add resolve() to DeviceSettings.__init__
1 file changed with 8 insertions and 2 deletions:
0 comments (0 inline, 0 general)
light9/effect/settings.py
Show inline comments
 
@@ -61,14 +61,20 @@ class _Settings:
 
    EntityType = DeviceUri
 
    AttrType = DeviceAttr
 

	
 
    def __init__(self, graph: GraphType, settingsList: List[Tuple[Any, Any, VTUnion]]):
 
        self.graph = graph  # for looking up all possible attrs
 
        self._compiled: Dict[self.__class__.EntityType, Dict[self.__class__.AttrType, VTUnion]] = {}
 
        for row in settingsList:
 
            self._compiled.setdefault(row[0], {})[row[1]] = row[2]
 
        for e, a, v in settingsList:
 
            attrVals = self._compiled.setdefault(e, {})
 
            if a in attrVals:
 
                v = resolve(
 
                    e,  # Hey, this is supposed to be DeviceClass (which is not convenient for us), but so far resolve() doesn't use that arg
 
                    a,
 
                    [attrVals[a], v])
 
            attrVals[a] = v
 
        # self._compiled may not be final yet- see _fromCompiled
 
        self._delZeros()
 

	
 
    @classmethod
 
    def _fromCompiled(cls, graph: GraphType, compiled: Dict[EntityType, Dict[AttrType, VTUnion]]):
 
        obj = cls(graph, [])
0 comments (0 inline, 0 general)