def _add_prop_stmts(self, prop): """Add property statements.""" if is_config_prop(prop): if is_reference_prop(prop): self._add_reference_stmts(prop) self._add_requisite_prop_stmts(prop) elif is_terminal_prop(prop): self._add_terminal_prop_stmts(prop)
def _print_test_case_compare(self, clazz): self._print_logging('Comparing leaf/leaf-lists...') for prop in clazz.properties(): if is_reference_prop(prop) or is_terminal_prop(prop): # unable to compare empty # read object will not be assigned to Empty() automatically if not is_empty_prop(prop): self._print_compare_stmt(prop)
def _add_leafref_path_key_stmts(self, prop): """Add leafref statements if the reference path has predicate needs to be set. """ orig_refstmt, _ = prop.stmt.i_leafref_ptr orig_refprop = orig_refstmt.i_property path_type_spec = prop.stmt.i_leafref if path_type_spec is None: return plist = path_type_spec.i_path_list _, pspec_list, _, _ = path_type_spec.path_spec if len(pspec_list) > len(plist): idx = 0 for _, pstmt in plist: idx += 1 pspec, pspec_list = pspec_list[0], pspec_list[1:] if pstmt.keyword == 'list': if len(pspec) == 4 and pspec[0] == 'predicate': pspec, pspec_list = pspec_list[0], pspec_list[1:] _, identifier, up, dn = pspec if up == 0: # absolute path continue path_prop = self._get_path_predicate_prop(prop, up, dn) # need to adjust value assigned according to predicate if is_reference_prop(path_prop): path = self._get_element_path(orig_refprop, length=idx) if isinstance(identifier, tuple): _, identifier = identifier path = self.path_sep.join([path, identifier]) value = self._get_element_path(path_prop) self.stmts.add_adjustment(path, value) elif is_terminal_prop(path_prop): self._add_terminal_prop_stmts(path_prop)