def node_sub(self, node_self, node_other):
deletes = []<EOL>puts = []<EOL>patches = []<EOL>def generate_delete(node, instance=True):<EOL><INDENT>composer = RestconfComposer(self.device, node)<EOL>url = '<STR_LIT>'.format(self.ip, self.port)<EOL>url += composer.get_url(instance=instance)<EOL>deletes.append(requests.Request('<STR_LIT>', url, headers=header_json))<EOL><DEDENT>def generate_put(node, instance=True):<EOL><INDENT>composer = RestconfComposer(self.device, node)<EOL>url = '<STR_LIT>'.format(self.ip, self.port)<EOL>url += composer.get_url(instance=instance)<EOL>data_json = composer.get_json(instance=instance)<EOL>puts.append(requests.Request('<STR_LIT>', url, headers=header_json,<EOL>data=data_json))<EOL><DEDENT>def generate_patch(node, instance=True):<EOL><INDENT>composer = RestconfComposer(self.device, node)<EOL>url = '<STR_LIT>'.format(self.ip, self.port)<EOL>url += composer.get_url(instance=instance)<EOL>data_json = composer.get_json(instance=instance)<EOL>patches.append(requests.Request('<STR_LIT>', url, headers=header_json,<EOL>data=data_json))<EOL><DEDENT>def list_seq_is_different(tag):<EOL><INDENT>s_list = [i for i in node_self.iterchildren(tag=tag)]<EOL>o_list = [i for i in node_other.iterchildren(tag=tag)]<EOL>if [self.device.get_xpath(n) for n in s_list] ==[self.device.get_xpath(n) for n in o_list]:<EOL><INDENT>return False<EOL><DEDENT>else:<EOL><INDENT>return True<EOL><DEDENT><DEDENT>def list_seq_is_inclusive(tag):<EOL><INDENT>s_list = [i for i in node_self.iterchildren(tag=tag)]<EOL>o_list = [i for i in node_other.iterchildren(tag=tag)]<EOL>s_seq = [self.device.get_xpath(n) for n in s_list]<EOL>o_seq = [self.device.get_xpath(n) for n in o_list]<EOL>if set(s_seq) <= set(o_seq) and[i for i in s_seq if i in o_seq] == o_seq:<EOL><INDENT>return True<EOL><DEDENT>else:<EOL><INDENT>return False<EOL><DEDENT><DEDENT>in_s_not_in_o, in_o_not_in_s, in_s_and_in_o =self._group_kids(node_self, node_other)<EOL>for child_s in in_s_not_in_o:<EOL><INDENT>schema_node = self.device.get_schema_node(child_s)<EOL>if schema_node.get('<STR_LIT:type>') == '<STR_LIT>' orschema_node.get('<STR_LIT:type>') == '<STR_LIT>':<EOL><INDENT>generate_patch(child_s)<EOL><DEDENT>elif schema_node.get('<STR_LIT:type>') == '<STR_LIT>' orschema_node.get('<STR_LIT:type>') == '<STR_LIT:list>':<EOL><INDENT>if schema_node.get('<STR_LIT>') == '<STR_LIT:user>':<EOL><INDENT>return ([], [generate_put(node_self, instance=True)], [])<EOL><DEDENT>else:<EOL><INDENT>generate_put(child_s, instance=True)<EOL><DEDENT><DEDENT><DEDENT>for child_o in in_o_not_in_s:<EOL><INDENT>schema_node = self.device.get_schema_node(child_o)<EOL>if schema_node.get('<STR_LIT:type>') == '<STR_LIT>' orschema_node.get('<STR_LIT:type>') == '<STR_LIT>':<EOL><INDENT>generate_delete(child_o)<EOL><DEDENT>elif schema_node.get('<STR_LIT:type>') == '<STR_LIT>' orschema_node.get('<STR_LIT:type>') == '<STR_LIT:list>':<EOL><INDENT>if schema_node.get('<STR_LIT>') == '<STR_LIT:user>':<EOL><INDENT>if list_seq_is_inclusive(child_o.tag):<EOL><INDENT>generate_delete(child_o, instance=True)<EOL><DEDENT>else:<EOL><INDENT>return ([], [generate_put(node_self, instance=True)],<EOL>[])<EOL><DEDENT><DEDENT>else:<EOL><INDENT>generate_delete(child_o, instance=True)<EOL><DEDENT><DEDENT><DEDENT>for child_s, child_o in in_s_and_in_o:<EOL><INDENT>schema_node = self.device.get_schema_node(child_s)<EOL>if schema_node.get('<STR_LIT:type>') == '<STR_LIT>':<EOL><INDENT>if child_s.text != child_o.text:<EOL><INDENT>generate_patch(child_s)<EOL><DEDENT><DEDENT>elif schema_node.get('<STR_LIT:type>') == '<STR_LIT>':<EOL><INDENT>if schema_node.get('<STR_LIT>') == '<STR_LIT:user>':<EOL><INDENT>if list_seq_is_different(child_s.tag):<EOL><INDENT>return ([], [generate_put(node_self, instance=True)],<EOL>[])<EOL><DEDENT><DEDENT><DEDENT>elif schema_node.get('<STR_LIT:type>') == '<STR_LIT>':<EOL><INDENT>if BaseCalculator(self.device, child_s, child_o).ne:<EOL><INDENT>x, y, z = self.node_sub(child_s, child_o)<EOL>deletes += x<EOL>puts += y<EOL>patches += z<EOL><DEDENT><DEDENT>elif schema_node.get('<STR_LIT:type>') == '<STR_LIT:list>':<EOL><INDENT>if schema_node.get('<STR_LIT>') == '<STR_LIT:user>':<EOL><INDENT>if list_seq_is_different(child_s.tag):<EOL><INDENT>return ([], [generate_put(node_self, instance=True)],<EOL>[])<EOL><DEDENT>else:<EOL><INDENT>if BaseCalculator(self.device, child_s, child_o).ne:<EOL><INDENT>x, y, z = self.node_sub(child_s, child_o)<EOL>deletes += x<EOL>puts += y<EOL>patches += z<EOL><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>if BaseCalculator(self.device, child_s, child_o).ne:<EOL><INDENT>x, y, z = self.node_sub(child_s, child_o)<EOL>deletes += x<EOL>puts += y<EOL>patches += z<EOL><DEDENT><DEDENT><DEDENT><DEDENT>return (deletes, puts, patches)<EOL>
node_sub

        High-level api: Compute the delta of two config nodes. This method is
        recursive. Assume two config nodes are different.

        Parameters
        ----------

        node_self : `Element`
            A config node in the destination config that is being processed.
            node_self cannot be a leaf node.

        node_other : `Element`
            A config node in the source config that is being processed.

        Returns
        -------

        tuple
            There are three elements in the tuple: a list of Restconf DELETE
            Requests, a list of Restconf PUT Requests, and a list of Restconf
            PATCH Requests.