Skip to content

Commit

Permalink
run linters
Browse files Browse the repository at this point in the history
  • Loading branch information
dmulyalin committed Aug 6, 2022
1 parent 0fcf3d0 commit e8cb92b
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions nornir_salt/utils/cfg_form_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def cfg_form_commands(task: Task, config: list = None, multiline: bool = False):
- extracting commands from host's __task__ data
- splitting multiline config string to a list of commands
- replaces escaped newline - \\n - with newline - \n
- replaces escaped newline - \\n - with newline - \n
:param task: (obj) Nornir Task object
:param config: (str or list) configuration string or list of commands to send to device
Expand All @@ -46,17 +46,17 @@ def cfg_form_commands(task: Task, config: list = None, multiline: bool = False):
# transform config to a list of commands if string given
elif isinstance(config, str):
config = config.splitlines()

# make sure to handle \\n in config
if isinstance(config, list):
cfg = []
for cfg_line in config:
if "\\n" in cfg_line:
cfg.extend(cfg_line.split("\\n"))
else:
cfg.append(cfg_line)
cfg.append(cfg_line)
config = cfg
elif isinstance(config, str) and "\\n" in config:
elif isinstance(config, str) and "\\n" in config:
config = config.replace("\\n", "\n")

return config

0 comments on commit e8cb92b

Please sign in to comment.