svghmi/hmi_tree.py
changeset 3817 3deeda82636a
parent 3750 f62625418bff
child 3854 d29d67e86532
equal deleted inserted replaced
3816:032bf4f225d0 3817:3deeda82636a
   148     def hash(self):
   148     def hash(self):
   149         """ Produce a hash, any change in HMI tree structure change that hash """
   149         """ Produce a hash, any change in HMI tree structure change that hash """
   150         s = hashlib.new('md5')
   150         s = hashlib.new('md5')
   151         self._hash(s)
   151         self._hash(s)
   152         # limit size to HMI_HASH_SIZE as in svghmi.c
   152         # limit size to HMI_HASH_SIZE as in svghmi.c
   153         return list(map(ord,s.digest()))[:8]
   153         return s.digest()[:8]
   154 
   154 
   155     def _hash(self, s):
   155     def _hash(self, s):
   156         s.update(str((self.name,self.nodetype)))
   156         s.update(self.name.encode() + self.nodetype.encode())
   157         if hasattr(self, "children"):
   157         if hasattr(self, "children"):
   158             for c in self.children:
   158             for c in self.children:
   159                 c._hash(s)
   159                 c._hash(s)
   160 
   160 
   161 SPECIAL_NODES = [("HMI_ROOT", "HMI_NODE"),
   161 SPECIAL_NODES = [("HMI_ROOT", "HMI_NODE"),