Skip to content

Commit

Permalink
Merge pull request #2 from cisco-ie/schema-from-path
Browse files Browse the repository at this point in the history
pyang --schema-from-path option
  • Loading branch information
remingtonc authored Nov 25, 2019
2 parents bf0bf09 + d173ab8 commit 2fb0e21
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion bin/pyang
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,11 @@ Validates the YANG module in <filename> (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 modules in path."),
optparse.make_option("--plugindir",
dest="plugindir",
help="Load pyang plugins from PLUGINDIR"),
Expand Down Expand Up @@ -291,14 +296,22 @@ Validates the YANG module in <filename> (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
sys.stderr.write(
"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(error.Position(''), 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()
Expand Down

0 comments on commit 2fb0e21

Please sign in to comment.