Skip to content
This repository has been archived by the owner on Sep 17, 2019. It is now read-only.

Commit

Permalink
Fix napalm validate so identical strings will work (#288)
Browse files Browse the repository at this point in the history
  • Loading branch information
ktbyers authored and dbarrosop committed Aug 2, 2017
1 parent 83d51ae commit 4865720
Showing 1 changed file with 20 additions and 15 deletions.
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 4865720

Please sign in to comment.