From 4c98e3a57d6126258c352914e344727d07000c88 Mon Sep 17 00:00:00 2001 From: Guoyou Zhang Date: Mon, 28 May 2018 04:34:24 +0200 Subject: [PATCH 1/2] remove logic to over-check submodule dependency for leaf-ref. for the detail bug, refer to issue#396 Change-Id: I979851ec224734d4a59f090587c0dd5d0e391b21 --- pyang/statements.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pyang/statements.py b/pyang/statements.py index 50eb4a00a..da82b63c3 100644 --- a/pyang/statements.py +++ b/pyang/statements.py @@ -2692,8 +2692,11 @@ def follow_path(ptr, up, dn): if ptr.keyword in _keyword_with_children: ptr = search_data_node(ptr.i_children, module_name, name, last_skipped) - if not is_submodule_included(path, ptr): - ptr = None + + ## comment out following 2 lines to fix issue #396 + ##if not is_submodule_included(path, ptr): + ## ptr = None + if ptr is None: err_add(ctx.errors, pathpos, 'LEAFREF_IDENTIFIER_NOT_FOUND', (module_name, name, stmt.arg, stmt.pos)) From 51c92ac4eb0021d112570439e797babeae10a1d9 Mon Sep 17 00:00:00 2001 From: Guoyou Zhang Date: Mon, 28 May 2018 12:38:10 +0200 Subject: [PATCH 2/2] fix issue#399 to keep yang file line number in yin file Change-Id: Ied8d814aaf338365f78603c40d70b030bb63afa8 --- pyang/translators/yin.py | 11 +++++++++-- pyang/yin_parser.py | 3 ++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/pyang/translators/yin.py b/pyang/translators/yin.py index 70adbbfe0..852a33318 100644 --- a/pyang/translators/yin.py +++ b/pyang/translators/yin.py @@ -28,6 +28,10 @@ def add_opts(self, optparser): dest="yin_pretty_strings", action="store_true", help="Pretty print strings"), + optparse.make_option("--yin-keep-line-number", + dest="yin_keep_line_number", + action="store_true", + help="Keep YANG file line number in yin file"), ] g = optparser.add_option_group("YIN output specific options") g.add_options(optlist) @@ -117,14 +121,17 @@ def emit_stmt(ctx, module, stmt, fd, indent, indentstep): (argname, argiselem) = syntax.yin_map[stmt.raw_keyword] tag = stmt.raw_keyword if argiselem == False or argname is None: + posatt = '' # fix issue#399 to add line number + if ctx.opts.yin_keep_line_number is not None: + posatt = ' line=' + quoteattr(str(stmt.pos.line)) if argname is None: attr = '' else: attr = ' ' + argname + '=' + quoteattr(stmt.arg) if len(stmt.substmts) == 0: - fd.write(indent + '<' + tag + attr + '/>\n') + fd.write(indent + '<' + tag + attr + posatt + '/>\n') else: - fd.write(indent + '<' + tag + attr + '>\n') + fd.write(indent + '<' + tag + attr + posatt + '>\n') for s in stmt.substmts: emit_stmt(ctx, module, s, fd, indent + indentstep, indentstep) diff --git a/pyang/yin_parser.py b/pyang/yin_parser.py index 2d9c30fd1..652050dec 100644 --- a/pyang/yin_parser.py +++ b/pyang/yin_parser.py @@ -223,7 +223,8 @@ def check_attr(self, pos, attrs): for at in attrs: (ns, local_name) = self.split_qname(at) if ns is None: - error.err_add(self.ctx.errors, pos, + if local_name != 'line': # fix issue#399 + error.err_add(self.ctx.errors, pos, 'UNEXPECTED_ATTRIBUTE', local_name) elif ns == yin_namespace: error.err_add(self.ctx.errors, pos,