def _print_class_constructor_body(self, clazz, leafs, children):
     self._print_init_children(children)
     if not clazz.is_identity():
         self.ctx.writeln('yang_name = "%s"; yang_parent_name = "%s"; is_top_level_class = %s; has_list_ancestor = %s; %s' \
                          % (clazz.stmt.arg, clazz.owner.stmt.arg, ('true' if is_top_level_class(clazz) else 'false'),
                             ('true' if has_list_ancestor(clazz) else 'false'),
                             ('is_presence_container = true;' if clazz.stmt.search_one('presence') is not None else '')))
Esempio n. 2
0
 def _print_class_inits_body(self, clazz, leafs, children):
     if clazz.is_identity():
         line = 'super(%s, self).__init__(ns, pref, tag)' % clazz.name
         self.ctx.writeln(line)
     else:
         if self.one_class_per_module:
             self.ctx.writeln('super(%s, self).__init__()' % clazz.name)
         else:
             self.ctx.writeln('super(%s, self).__init__()' % clazz.qn())
         if clazz.owner is not None and isinstance(clazz.owner, Package):
             self.ctx.writeln('self._top_entity = None')
         self.ctx.bline()
         if self.one_class_per_module:
             self._print_children_imports(clazz, children)
         self.ctx.writeln('self.yang_name = "%s"' % clazz.stmt.arg)
         self.ctx.writeln('self.yang_parent_name = "%s"' % clazz.owner.stmt.arg)
         self.ctx.writeln('self.is_top_level_class = %s' % ('True' if is_top_level_class(clazz) else 'False'))
         self.ctx.writeln('self.has_list_ancestor = %s' % ('True' if has_list_ancestor(clazz) else 'False'))
         self.ctx.writeln(
             'self.ylist_key_names = [%s]' % (','.join(["'%s'" % key.name for key in clazz.get_key_props()])))
         self.ctx.writeln(
             'self._child_classes = OrderedDict([%s])' % (get_child_classes(clazz, self.one_class_per_module)))
         if clazz.stmt.search_one('presence') is not None:
             self.ctx.writeln('self.is_presence_container = True')
         self._print_init_leafs_and_leaflists(clazz, leafs)
         self._print_init_children(children)
         self._print_init_lists(clazz)
         self._print_class_segment_path(clazz)
         self._print_class_absolute_path(clazz, leafs)
         self.ctx.writeln('self._is_frozen = True')
Esempio n. 3
0
 def _print_class_constructor_body(self, clazz, leafs, children):
     self._print_init_children(children)
     if not clazz.is_identity():
         self.ctx.writeln('yang_name = "%s"; yang_parent_name = "%s"; is_top_level_class = %s; has_list_ancestor = %s; %s' \
                          % (clazz.stmt.arg, clazz.owner.stmt.arg, ('true' if is_top_level_class(clazz) else 'false'),
                             ('true' if has_list_ancestor(clazz) else 'false'),
                             ('is_presence_container = true;' if clazz.stmt.search_one('presence') is not None else '')))
Esempio n. 4
0
 def _print_class_inits_body(self, clazz, leafs, children):
     if clazz.is_identity():
         module_name = get_module_name(clazz.stmt)
         namespace = self.module_namespace_lookup[module_name]
         line = 'super(%s, self).__init__("%s", "%s", "%s:%s")' % (clazz.name, namespace, module_name, module_name, clazz.stmt.arg)
         self.ctx.writeln(line)
     else:
         if self.one_class_per_module:
             self.ctx.writeln('super(%s, self).__init__()' % clazz.name)
         else:
             self.ctx.writeln('super(%s, self).__init__()' % clazz.qn())
         if clazz.owner is not None and isinstance(clazz.owner, Package):
             self.ctx.writeln('self._top_entity = None')
         self.ctx.bline()
         if self.one_class_per_module:
             self._print_children_imports(clazz, children)
         self.ctx.writeln('self.yang_name = "%s"' % clazz.stmt.arg)
         self.ctx.writeln('self.yang_parent_name = "%s"' % clazz.owner.stmt.arg)
         self.ctx.writeln('self.is_top_level_class = %s' % ('True' if is_top_level_class(clazz) else 'False'))
         self.ctx.writeln('self.has_list_ancestor = %s' % ('True' if has_list_ancestor(clazz) else 'False'))
         self.ctx.writeln(
             'self.ylist_key_names = [%s]' % (','.join(["'%s'" % key.name for key in clazz.get_key_props()])))
         self.ctx.writeln('self._child_container_classes = OrderedDict([%s])' % (get_child_container_classes(clazz, self.one_class_per_module)))
         self.ctx.writeln('self._child_list_classes = OrderedDict([%s])' % (get_child_list_classes(clazz, self.one_class_per_module)))
         if clazz.stmt.search_one('presence') is not None:
             self.ctx.writeln('self.is_presence_container = True')
         self._print_init_leafs_and_leaflists(clazz, leafs)
         self._print_init_children(children)
         self._print_init_lists(clazz)
         self._print_class_segment_path(clazz)
         self._print_class_absolute_path(clazz, leafs)
Esempio n. 5
0
    def print_output(self, clazz, leafs):
        """

            :param `api_model.Class` clazz The class object.

        """
        if not is_top_level_class(clazz) and not has_list_ancestor(clazz):
            self._print_absolute_path_body(clazz, leafs)
    def print_output(self, clazz, leafs):
        """

            :param `api_model.Class` clazz The class object.

        """
        if not is_top_level_class(clazz) and not has_list_ancestor(clazz):
            self._print_absolute_path_body(clazz, leafs)
    def print_output(self, clazz):
        """
            Print the get_entity_path method for the clazz.

            :param `api_model.Class` clazz The class object.

        """
        if not is_top_level_class(clazz) and not has_list_ancestor(clazz):
            self._print_get_entity_path_header(clazz)
            self._print_get_entity_path_body(clazz)
            self._print_get_entity_path_trailer(clazz)
    def print_output(self, clazz):
        """
            Print the get_entity_path method for the clazz.

            :param `api_model.Class` clazz The class object.

        """
        if not is_top_level_class(clazz) and not has_list_ancestor(clazz):
            self._print_get_entity_path_header(clazz)
            self._print_get_entity_path_body(clazz)
            self._print_get_entity_path_trailer(clazz)
Esempio n. 9
0
 def _print_common_method_declarations(self, clazz):
     self.ctx.writeln('bool has_data() const override;')
     self.ctx.writeln('bool has_operation() const override;')
     self.ctx.writeln('std::vector<std::pair<std::string, ydk::LeafData> > get_name_leaf_data() const override;')
     self.ctx.writeln('std::string get_segment_path() const override;')
     self.ctx.writeln('std::shared_ptr<ydk::Entity> get_child_by_name(const std::string & yang_name, const std::string & segment_path) override;')
     self.ctx.writeln('void set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) override;')
     self.ctx.writeln('void set_filter(const std::string & value_path, ydk::YFilter yfliter) override;')
     self.ctx.writeln('std::map<std::string, std::shared_ptr<ydk::Entity>> get_children() const override;')
     self.ctx.writeln('bool has_leaf_or_child_of_name(const std::string & name) const override;')
     if not is_top_level_class(clazz) and not has_list_ancestor(clazz):
         self.ctx.writeln('std::string get_absolute_path() const override;')
Esempio n. 10
0
 def _print_common_method_declarations(self, clazz):
     self.ctx.writeln('bool has_data() const override;')
     self.ctx.writeln('bool has_operation() const override;')
     self.ctx.writeln(
         'std::vector<std::pair<std::string, ydk::LeafData> > get_name_leaf_data() const override;'
     )
     self.ctx.writeln('std::string get_segment_path() const override;')
     self.ctx.writeln(
         'std::shared_ptr<ydk::Entity> get_child_by_name(const std::string & yang_name, const std::string & segment_path) override;'
     )
     self.ctx.writeln(
         'void set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) override;'
     )
     self.ctx.writeln(
         'void set_filter(const std::string & value_path, ydk::YFilter yfliter) override;'
     )
     self.ctx.writeln(
         'std::map<std::string, std::shared_ptr<ydk::Entity>> get_children() const override;'
     )
     self.ctx.writeln(
         'bool has_leaf_or_child_of_name(const std::string & name) const override;'
     )
     if not is_top_level_class(clazz) and not has_list_ancestor(clazz):
         self.ctx.writeln('std::string get_absolute_path() const override;')
Esempio n. 11
0
 def _print_class_constructor_body(self, clazz, leafs, children):
     self._print_init_children(children)
     if not clazz.is_identity():
         self.ctx.writeln('yang_name = "%s"; yang_parent_name = "%s"; is_top_level_class = %s; has_list_ancestor = %s;' \
                          % (clazz.stmt.arg, clazz.owner.stmt.arg, ('true' if is_top_level_class(clazz) else 'false'),
                             ('true' if has_list_ancestor(clazz) else 'false')))