Skip to content

Commit

Permalink
dependencies updates; any() handling improvement; bump to version 0.13.0
Browse files Browse the repository at this point in the history
  • Loading branch information
dmulyalin committed Jul 17, 2022
1 parent 1cbd16f commit 835355a
Show file tree
Hide file tree
Showing 8 changed files with 582 additions and 487 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# pre-commit run --all-files

default_language_version:
python: python3.7
python: python3.9

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
Expand Down
8 changes: 3 additions & 5 deletions nornir_salt/plugins/functions/FFun.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ def _filter_FB(ret, pattern):
# run filtering
if isinstance(pattern, list):
return ret.filter(
filter_func=lambda h: any([fnmatchcase(h.name, str(p)) for p in pattern])
filter_func=lambda h: any(fnmatchcase(h.name, str(p)) for p in pattern)
)
else:
return ret.filter(filter_func=lambda h: fnmatchcase(h.name, str(pattern)))
Expand Down Expand Up @@ -361,9 +361,7 @@ def _filter_FC(ret, pattern):
pattern = [i.strip() for i in pattern.split(",")]
# run filtering
if isinstance(pattern, list):
return ret.filter(
filter_func=lambda h: any([str(p) in h.name for p in pattern])
)
return ret.filter(filter_func=lambda h: any(str(p) in h.name for p in pattern))
else:
return ret.filter(filter_func=lambda h: str(pattern) in h.name)

Expand All @@ -377,7 +375,7 @@ def _filter_FR(ret, pattern):
# run filtering
if isinstance(pattern, list):
return ret.filter(
filter_func=lambda h: any([re.search(str(p), h.name) for p in pattern])
filter_func=lambda h: any(re.search(str(p), h.name) for p in pattern)
)
else:
return ret.filter(
Expand Down
2 changes: 1 addition & 1 deletion nornir_salt/plugins/processors/DataProcessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -994,7 +994,7 @@ def key_filter(data, pattern=None, checks_required=True, **kwargs):
return {
k: data[k]
for k in data.keys()
if any([c["fun"](k, c["criteria"]) for c in checks])
if any(c["fun"](k, c["criteria"]) for c in checks)
}


Expand Down
59 changes: 0 additions & 59 deletions nornir_salt/plugins/processors/N2GProcessor.py

This file was deleted.

8 changes: 6 additions & 2 deletions nornir_salt/plugins/tasks/netmiko_send_command_ps.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,12 @@ def send_command_ps(
time.sleep(inter_loop_sleep)
no_data_elapsed += inter_loop_sleep

# read data from channel
chunk = self._read_channel()
# read data from channel for netmiko 3
if hasattr(self, "_read_channel"):
chunk = self._read_channel()
# read data from channel for netmiko 4
else:
chunk = self.read_channel()
if chunk:
no_data_elapsed = 0
data_received += chunk
Expand Down
2 changes: 1 addition & 1 deletion nornir_salt/utils/cli_send_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def cli_send_commands(
stop_patern_matched = (
True
if stop_patern_matched is True
else any([fnmatchcase(str(r.result), stop_pattern) for r in res])
else any(fnmatchcase(str(r.result), stop_pattern) for r in res)
)
# do not wait after last command sent
if index + 1 < len(commands):
Expand Down
Loading

0 comments on commit 835355a

Please sign in to comment.