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

Commit

Permalink
Intelligent defaults and raise exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
bewing committed Jul 1, 2017
1 parent 1bf7100 commit e1b5e8c
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions napalm_yang/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,14 @@ def _execute_methods(self, device, methods):
result = []
for m in methods:
attr = device
args = []
kwargs = {}
for p in m["method"].split("."):
attr = getattr(attr, p)
if isinstance(m.get("args", None), list):
args = m["args"]
if isinstance(m.get("kwargs", None), dict):
kwargs = m["kwargs"]
args = m.get("args", [])
if not isinstance(args, list):
raise TypeError("args must be type list, not type {}".format(type(args)))
kwargs = m.get("kwargs", {})
if not isinstance(args, dict):
raise TypeError("kwargs must be type dict, not type {}".format(type(kwargs)))
r = attr(*args, **kwargs)

if isinstance(r, dict) and all([isinstance(x, (str, unicode)) for x in r.values()]):
Expand Down

0 comments on commit e1b5e8c

Please sign in to comment.