From c52d5daf4d196ba2e948f70a056f54827ac4d3cb Mon Sep 17 00:00:00 2001 From: Remington Campbell Date: Fri, 22 Nov 2019 23:01:12 -0800 Subject: [PATCH 1/3] --schema-from-path - Lood all modules from path --- bin/pyang | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/bin/pyang b/bin/pyang index be23f3b1b..99be210fc 100755 --- a/bin/pyang +++ b/bin/pyang @@ -132,6 +132,11 @@ Validates the YANG module in (or stdin), and all its dependencies.""" action="append", help=os.pathsep + "-separated search path for yin" " and yang modules"), + optparse.make_option("--schema-from-path", + dest="schema_from_path", + default=False, + action="store_true", + help="Automatically load all YANG in path."), optparse.make_option("--plugindir", dest="plugindir", help="Load pyang plugins from PLUGINDIR"), @@ -299,6 +304,14 @@ Validates the YANG module in (or stdin), and all its dependencies.""" "module '%s' specified in hello not found.\n" % emarg) sys.exit(1) modules.append(mod) + elif o.schema_from_path: + for module_name in ctx.revs.keys(): + module = ctx.search_module(0, module_name) + if module is None: + sys.stderr.write( + "module '%s' failed to load in schema parsing.\n" % module_name) + sys.exit(1) + modules.append(module) else: if len(filenames) == 0: text = sys.stdin.read() From d4bef07254d8f80f12769884e8b43dd10b62b104 Mon Sep 17 00:00:00 2001 From: Remington Campbell Date: Mon, 25 Nov 2019 07:55:44 -0800 Subject: [PATCH 2/3] Clarify YANG -> YANG modules --- bin/pyang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/pyang b/bin/pyang index 99be210fc..c9374a1ba 100755 --- a/bin/pyang +++ b/bin/pyang @@ -136,7 +136,7 @@ Validates the YANG module in (or stdin), and all its dependencies.""" dest="schema_from_path", default=False, action="store_true", - help="Automatically load all YANG in path."), + help="Automatically load all YANG modules in path."), optparse.make_option("--plugindir", dest="plugindir", help="Load pyang plugins from PLUGINDIR"), From d173ab883297c1da277077d875a48bc8320a932d Mon Sep 17 00:00:00 2001 From: Remington Campbell Date: Mon, 25 Nov 2019 08:02:18 -0800 Subject: [PATCH 3/3] Use error.Position in search_module --- bin/pyang | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/pyang b/bin/pyang index c9374a1ba..105afca63 100755 --- a/bin/pyang +++ b/bin/pyang @@ -296,7 +296,7 @@ Validates the YANG module in (or stdin), and all its dependencies.""" if o.hello: ctx.capabilities = hel.registered_capabilities() for (mn,rev) in hel.yang_modules(): - mod = ctx.search_module(0, mn, rev) + mod = ctx.search_module(error.Position(''), mn, rev) if mod is None: emarg = mn if rev: emarg += "@" + rev @@ -306,7 +306,7 @@ Validates the YANG module in (or stdin), and all its dependencies.""" modules.append(mod) elif o.schema_from_path: for module_name in ctx.revs.keys(): - module = ctx.search_module(0, module_name) + module = ctx.search_module(error.Position(''), module_name) if module is None: sys.stderr.write( "module '%s' failed to load in schema parsing.\n" % module_name)