示例#1
0
    def _add_terminal_prop_stmts(self, prop):
        """Add test case statements for leaf or leaf-list."""
        path = self._get_element_path(prop)
        if is_leaflist_prop(prop):
            path = '{}[0]'.format(path)
            value = self._get_value(prop)
            if isinstance(value, BitsValue):
                return
                # # ConfD internal error for leaflist of bits
                # path, value = self._render_bits_value(path, value.val)
                # self.stmts.add_assignment(path, value)
            self._add_declaration_stmt(prop)
            self._add_leaflist_append_stmts(prop)
        else:
            value = self._get_value(prop)
            if isinstance(value, BitsValue):
                if self.lang == 'py' and is_union_prop(prop):
                    # add additional dec, assignment stmt
                    # for UnionType contains Bits
                    dec_obj = self._get_element_path(value.type_spec)
                    dec = get_qn(self.lang, value.type_spec)
                    self.stmts.add_assignment(path, dec_obj)
                    self.stmts.add_declaration(dec_obj, dec)

                path, value = self._render_bits_value(path, value.val)

            self.stmts.add_assignment(path, value)
示例#2
0
    def _add_terminal_prop_stmts(self, prop):
        """Add test case statements for leaf or leaf-list."""
        path = self._get_element_path(prop)
        if is_leaflist_prop(prop):
            path = '{}[0]'.format(path)
            value = self._get_value(prop)
            if isinstance(value, BitsValue):
                return
                # # ConfD internal error for leaflist of bits
                # path, value = self._render_bits_value(path, value.val)
                # self.stmts.add_assignment(path, value)
            self._add_declaration_stmt(prop)
            self._add_leaflist_append_stmts(prop)
        else:
            value = self._get_value(prop)
            if isinstance(value, BitsValue):
                if self.lang == 'py' and is_union_prop(prop):
                    # add additional dec, assignment stmt
                    # for UnionType contains Bits
                    dec_obj = self._get_element_path(value.type_spec)
                    dec = get_qn(self.lang, value.type_spec)
                    self.stmts.add_assignment(path, dec_obj)
                    self.stmts.add_declaration(dec_obj, dec)

                path, value = self._render_bits_value(path, value.val)

            self.stmts.add_assignment(path, value)
示例#3
0
 def _add_reference_stmt(self, prop, refprop):
     """Add reference statements."""
     path = self._get_element_path(prop)
     refpath = self._get_element_path(refprop)
     value = self._get_value(refprop)
     if is_leaflist_prop(prop):
         self.stmts.add_leaflist_append(path, refpath)
     else:
         self.stmts.add_reference(path, refpath)
     if is_reference_prop(refprop):
         prop = refprop
         refprop, _ = self._get_reference_prop(prop)
         self._add_reference_stmt(prop, refprop)
     else:
         self._add_requisite_stmts(refprop.owner)
         self.stmts.add_assignment(refpath, value)
示例#4
0
 def _add_reference_stmt(self, prop, refprop):
     """Add reference statements."""
     path = self._get_element_path(prop)
     refpath = self._get_element_path(refprop)
     value = self._get_value(refprop)
     if is_leaflist_prop(prop):
         self.stmts.add_leaflist_append(path, refpath)
     else:
         self.stmts.add_reference(path, refpath)
     if is_reference_prop(refprop):
         prop = refprop
         refprop, _ = self._get_reference_prop(prop)
         self._add_reference_stmt(prop, refprop)
     else:
         self._add_requisite_stmts(refprop.owner)
         self.stmts.add_assignment(refpath, value)