Skip to content

Commit

Permalink
Merge pull request #144 from ktbyers/using_builtin
Browse files Browse the repository at this point in the history
Fix issues with using built-in and overwriting variable with loop variable
  • Loading branch information
dbarrosop committed May 21, 2018
2 parents 962915a + 666150f commit 9846815
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
13 changes: 8 additions & 5 deletions nornir/core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,26 @@ def _pickle_method(method):
return _unpickle_method, (func_name, obj, cls)

def _unpickle_method(func_name, obj, cls):
for cls in cls.mro():
for cls_tmp in cls.mro():
try:
func = cls.__dict__[func_name]
func = cls_tmp.__dict__[func_name]
except KeyError:
pass
else:
break

return func.__get__(obj, cls)
else:
raise ValueError("Method ({}) not found for obj: {}".format(func_name, obj))

return func.__get__(obj, cls_tmp)

copy_reg.pickle(types.MethodType, _pickle_method, _unpickle_method)


class Data(object):
"""
This class is just a placeholder to share data amongsts different
versions of Nornir after running ``filter`` multiple times.
This class is just a placeholder to share data amongst different
versions of Nornir after running ``filter`` multiple times.
Attributes:
failed_hosts (list): Hosts that have failed to run a task properly
Expand Down
6 changes: 3 additions & 3 deletions nornir/core/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
types = {"int": int, "str": str}


class Config:
class Config(object):
"""
This object handles the configuration of Nornir.
Expand Down Expand Up @@ -112,8 +112,8 @@ def __init__(self, config_file=None, **kwargs):
obj = self._resolve_import_from_string(kwargs.get(r, getattr(self, r)))
setattr(self, r, obj)

callable = ["jinja_filters"]
for c in callable:
callable_func = ["jinja_filters"]
for c in callable_func:
func = getattr(self, c)
if func:
setattr(self, c, func())
Expand Down

0 comments on commit 9846815

Please sign in to comment.