Put a guard in the yang validator against trying to read a draft which is absent from the staging area.

- Legacy-Id: 10958
This commit is contained in:
Henrik Levkowetz 2016-03-21 11:42:06 +00:00
parent 96d62b8aaa
commit f52e21fb17

View file

@ -111,9 +111,13 @@ class DraftYangChecker(object):
def check_file_txt(self, path):
name = os.path.basename(path)
workdir = tempfile.mkdtemp()
errors = []
warnings = []
results = {}
extractor = xym.YangModuleExtractor(path, workdir, strict=True, debug_level = 0)
if not os.path.exists(path):
return None, "%s: No such file or directory: '%s'"%(name.capitalize(), path), errors, warnings, results
with open(path) as file:
try:
# This places the yang models as files in workdir