svghmi/svghmi.py
branchsvghmi
changeset 2945 69f395c01c09
parent 2890 ae8063127e95
child 2965 8f928cee01e5
equal deleted inserted replaced
2942:b07ad97e6019 2945:69f395c01c09
    76                 for child_path_item, node_path_item in izip(child.path, node.path):
    76                 for child_path_item, node_path_item in izip(child.path, node.path):
    77                     if child_path_item == node_path_item:
    77                     if child_path_item == node_path_item:
    78                         in_common +=1
    78                         in_common +=1
    79                     else:
    79                     else:
    80                         break
    80                         break
    81                 if in_common > known_best_match:
    81                 # Match can only be HMI_NODE, and the whole path of node
       
    82                 # must match candidate node (except for name part)
       
    83                 # since candidate would become child of that node
       
    84                 if in_common > known_best_match and \
       
    85                    child.nodetype == "HMI_NODE" and \
       
    86                    in_common == len(child.path) - 1:
    82                     known_best_match = in_common
    87                     known_best_match = in_common
    83                     best_child = child
    88                     best_child = child
    84         if best_child is not None and best_child.nodetype == "HMI_NODE":
    89         if best_child is not None:
    85             best_child.place_node(node)
    90             best_child.place_node(node)
    86         else:
    91         else:
    87             self.children.append(node)
    92             self.children.append(node)
    88 
    93 
    89     def etree(self, add_hash=False):
    94     def etree(self, add_hash=False):