Exemple #1
0
 def __init__(self, prop):
     self.name = prop.stmt.arg
     self.mtype = ''
     self.ptype = ''
     self.ytype = ''
     self.prange = []
     self.pattern = []
     self.presentation_name = "%s" % prop.name
     self.module_name = "%s" % get_module_name(prop.stmt)
     self.pmodule_name = None
     self.clazz_name = None
     self.is_many = prop.is_many
     self.doc_link = None
     self.doc_link_description = ''
     self.children = []
     self.comment = prop.comment
     self.is_key = prop.is_key()
     self.max_elements = prop.max_elements
     self.min_elements = prop.min_elements
     self.target_of_leafref = ''
     self.mandatory = False
     self.is_presence = False
     self.units = ''
     self.default_value = ''
     self.default_value_object = None
     self.is_config = is_config_stmt(prop.stmt)
     self.status = ''
Exemple #2
0
 def __init__(self, prop):
     self.name = prop.stmt.arg
     self.mtype = ''
     self.ptype = ''
     self.ytype = ''
     self.prange = []
     self.pattern = []
     self.presentation_name = "%s" % prop.name
     self.module_name = "%s" % get_module_name(prop.stmt)
     self.pmodule_name = None
     self.clazz_name = None
     self.is_many = prop.is_many
     self.doc_link = None
     self.doc_link_description = ''
     self.children = []
     self.comment = prop.comment
     self.is_key = prop.is_key()
     self.max_elements = prop.max_elements
     self.min_elements = prop.min_elements
     self.target_of_leafref = ''
     self.mandatory = False
     self.is_presence = False
     self.units = ''
     self.default_value = ''
     self.default_value_object = None
     self.is_config = is_config_stmt(prop.stmt)
     self.status = ''
Exemple #3
0
 def _print_class_rst(self, clazz):
     self._print_namespace(clazz)
     self._print_header(clazz)
     # Body
     self.ctx.lvl_inc()
     self._print_bases(clazz)
     self._print_class_hierarchy(clazz)
     if clazz.stmt.search_one('presence') is not None:
         self._append('This class is a :ref:`presence class<presence-class>`\n')
     if clazz.stmt.keyword != 'rpc':
         if is_config_stmt(clazz.stmt):
             self._append('This class represents configuration data.\n')
         else:
             self._append('This class represents state data.\n')
     else:
         self._append('This class defines parameters to the RPC operation\n')
     self._print_docstring(clazz, get_class_docstring(
         clazz, self.lang, identity_subclasses=self.identity_subclasses))
     self.ctx.lvl_dec()
Exemple #4
0
    def _print_class_rst(self, clazz):
        self._print_namespace(clazz)
        self._print_header(clazz)
        # Body
        self.ctx.lvl_inc()
        if self.lang != 'go':
            self._print_bases(clazz)
            self._print_class_hierarchy(clazz)
        if clazz.stmt.search_one('presence') is not None:
            self._append('This class is a :ref:`presence class<presence-class>`\n')
        if clazz.stmt.keyword != 'rpc':
            if is_config_stmt(clazz.stmt):
                self._append('This class represents configuration data.\n')
            else:
                self._append('This class represents state data.\n')
        else:
            self._append('This class defines parameters to the RPC operation\n')

        docstring = get_class_docstring(
            clazz, self.lang, identity_subclasses=self.identity_subclasses)
        self._print_docstring(clazz, docstring)
        self.ctx.lvl_dec()
    def _print_meta_member(self, clazz):
        mtype = 'REFERENCE_CLASS'
        if clazz.stmt.keyword == 'list':
            mtype = 'REFERENCE_LIST'
        elif clazz.stmt.keyword == 'leaf-list':
            mtype = 'REFERENCE_LEAFLIST'
        elif clazz.stmt.keyword == 'identity':
            mtype = 'REFERENCE_IDENTITY_CLASS'
        self.ctx.writeln('\'%s\' : {' % (clazz.qn()))
        self.ctx.lvl_inc()
        self.ctx.writeln("'meta_info' : _MetaInfoClass('%s', %s," %
                         (clazz.qn(), mtype))
        self.ctx.lvl_inc()
        description = " "
        for st in clazz.stmt.substmts:
            if st.keyword == 'description':
                description = st.arg
                break
        self.ctx.writeln("'''%s'''," % description)
        if clazz.is_grouping():
            self.ctx.writeln('True, ')
        else:
            self.ctx.writeln('False, ')
        self.ctx.writeln('[')

        if self.is_rpc:
            prop_list = [
                p for p in clazz.owned_elements if isinstance(p, Property)
            ]
        else:
            prop_list = clazz.properties()

        for prop in prop_list:
            meta_info_data = get_meta_info_data(prop, prop.property_type,
                                                prop.stmt.search_one('type'),
                                                'py', self.identity_subclasses)
            self.print_meta_class_member(meta_info_data, self.ctx)

        self.ctx.writeln('],')
        module_name = "%s" % get_module_name(clazz.stmt)
        self.ctx.writeln("'%s'," % module_name)
        self.ctx.writeln("'%s'," % clazz.stmt.arg)
        if clazz.is_grouping():
            self.ctx.writeln('None,')
        else:
            self.ctx.writeln("_yang_ns.NAMESPACE_LOOKUP['%s']," % module_name)
        self.ctx.writeln("'%s'," % clazz.get_py_mod_name())
        if mtype == 'REFERENCE_CLASS' or mtype == 'REFERENCE_LIST':
            if not is_config_stmt(clazz.stmt):
                self.ctx.writeln("is_config=False,")
            if clazz.stmt.search_one('presence'):
                self.ctx.writeln("is_presence=True,")
            if clazz.stmt.search_one('mandatory'):
                self.ctx.writeln("has_mandatory=True,")
            if clazz.stmt.search_one('when'):
                self.ctx.writeln("has_when=True,")
            if clazz.stmt.search_one('must'):
                self.ctx.writeln("has_must=True,")
        self.ctx.lvl_dec()
        self.ctx.writeln('),')

        self.ctx.lvl_dec()
        self.ctx.writeln('},')