Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:napalm-automation/napalm-base in…
Browse files Browse the repository at this point in the history
…to develop

* 'develop' of github.com:napalm-automation/napalm-base:
  Correct link under "compliance_report" function (napalm-automation#289)
  Fix napalm validate so identical strings will work (napalm-automation#288)
  • Loading branch information
bewing committed Aug 4, 2017
2 parents 7e782fc + ef47e15 commit ef4fbbb
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 16 deletions.
2 changes: 1 addition & 1 deletion napalm_base/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1542,6 +1542,6 @@ def compliance_report(self, validation_file='validate.yml'):
Return a compliance report.
Verify that the device complies with the given validation file and writes a compliance
report file. See https://napalm.readthedocs.io/en/latest/validate.html.
report file. See https://napalm.readthedocs.io/en/latest/validate/index.html.
"""
return validate.compliance_report(self, validation_file=validation_file)
35 changes: 20 additions & 15 deletions napalm_base/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,22 +123,27 @@ def _compare_getter(src, dst):

return _compare_getter_list(src['list'], dst, mode)
return _compare_getter_dict(src, dst, mode)
else:
if isinstance(src, py23_compat.string_types):
if src.startswith('<') or src.startswith('>'):
cmp_result = compare_numeric(src, dst)
return cmp_result
else:
m = re.search(src, py23_compat.text_type(dst))
return m is not None
elif(type(src) == type(dst) == list):
pairs = zip(src, dst)
diff_lists = [[(k, x[k], y[k])
for k in x if not re.search(x[k], y[k])]
for x, y in pairs if x != y]
return empty_tree(diff_lists)

elif isinstance(src, py23_compat.string_types):
if src.startswith('<') or src.startswith('>'):
cmp_result = compare_numeric(src, dst)
return cmp_result
else:
return src == dst
m = re.search(src, py23_compat.text_type(dst))
if m:
return bool(m)
else:
return src == dst

elif(type(src) == type(dst) == list):
pairs = zip(src, dst)
diff_lists = [[(k, x[k], y[k])
for k in x if not re.search(x[k], y[k])]
for x, y in pairs if x != y]
return empty_tree(diff_lists)

else:
return src == dst


def compare_numeric(src_num, dst_num):
Expand Down

0 comments on commit ef4fbbb

Please sign in to comment.