Skip to content
12 changes: 6 additions & 6 deletions src/ncdiff/composer.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,9 @@ def model_name(self):
ret = re.search(Tag.BRACE[0], self.path[0])
if ret:
url_to_name = {i[2]: i[0] for i in self.device.namespaces
if i[1] is not None}
if i[1] is not None and i[2] == ret.group(1)}
if ret.group(1) in url_to_name:
raise ModelMissing("please load model '{}' by calling "
"method load_model() of device {}"
.format(url_to_name[ret.group(1)],
self.device))
return url_to_name[ret.group(1)]
else:
raise ModelMissing("unknown model url '{}'"
.format(ret.group(1)))
Expand All @@ -123,7 +120,10 @@ def model_name(self):

@property
def model_ns(self):
return self.device.models[self.model_name].url
name_to_url = {i[0]: i[2] for i in self.device.namespaces
if i[1] is not None and i[0] == self.model_name}
return name_to_url[self.model_name] if self.model_name in name_to_url \
else None

@property
def is_config(self):
Expand Down
4 changes: 3 additions & 1 deletion src/ncdiff/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,9 @@ def scan_models(self, folder='./yang', download='check'):
if download in ['check', 'force']:
d = ModelDownloader(self, folder)
d.download_all(check_before_download=(download == 'check'))
self.compiler = ModelCompiler(folder)
self.compiler = ModelCompiler(folder, context=d.context)
else:
self.compiler = ModelCompiler(folder)

def load_model(self, model):
'''load_model
Expand Down
503 changes: 468 additions & 35 deletions src/ncdiff/model.py

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/ncdiff/ref.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ def parse_square_bracket(self, to_node=None):
self.cut(start_idx+1, end_idx-2, tag, 2)
start_idx = None
else:
if re.search('^\[[1-9][0-9]*\]$', substring):
if re.search(r'^\[[1-9][0-9]*\]$', substring):
numbers = substring[1:-1]
self.cut(start_idx+1, end_idx-1, numbers, 2)
else:
Expand Down
Loading