Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pyang --schema-from-path option #2

Merged
merged 3 commits into from
Nov 25, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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