Skip to content

Commit

Permalink
fix flake8 issues
Browse files Browse the repository at this point in the history
Signed-off-by: Sumit Jaiswal <[email protected]>
  • Loading branch information
justjais committed Jun 12, 2024
1 parent 2f9ce96 commit 5f98078
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions ansible_risk_insight/finder.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import yaml
import traceback
from ansible_risk_insight.yaml_utils import FormattedYAML
from ruamel.yaml.comments import CommentedMap, CommentedSeq

try:
# if `libyaml` is available, use C based loader for performance
Expand Down Expand Up @@ -766,7 +765,7 @@ def populate_new_data_list(data, line_number_list):
input_line_number = int(each.lstrip("L").split("-")[0])
break
temp_data = data.splitlines(keepends=True)
return temp_data[0:input_line_number-1]
return temp_data[0:input_line_number - 1]


def check_and_add_diff_lines(start_line, stop_line, lines, data_copy):
Expand All @@ -776,7 +775,7 @@ def check_and_add_diff_lines(start_line, stop_line, lines, data_copy):
"""
diff_in_line = stop_line - start_line
data_copy.append('\n')
for i in range(start_line, (start_line+diff_in_line)-1):
for i in range(start_line, (start_line + diff_in_line) - 1):
line = lines[i]
data_copy.append(line)

Expand Down Expand Up @@ -806,7 +805,7 @@ def update_the_yaml_target(file_path, line_number_list, new_content_list):
diff_in_lines = stop_line_number - start_line_number
temp_content = []
data_copy.append('\n')
for i in range(start_line_number-1, stop_line_number-1):
for i in range(start_line_number - 1, stop_line_number - 1):
line_number = i
if len(lines) == i or j >= len(new_lines):
break
Expand All @@ -824,7 +823,7 @@ def update_the_yaml_target(file_path, line_number_list, new_content_list):
data_copy.append(lines[line_number])
else:
new_line_key = new_line_content.split(':')
for k in range(start_line_number-1, stop_line_number-1):
for k in range(start_line_number - 1, stop_line_number - 1):
if k < len(lines):
old_line_key = lines[k].split(':')
if '---' in old_line_key[0]:
Expand All @@ -835,9 +834,9 @@ def update_the_yaml_target(file_path, line_number_list, new_content_list):
# diff_in_lines = len(lines) - len(new_lines)
leading_spaces = len(lines[k]) - len(lines[k].lstrip())
if diff_in_lines > len(lines):
for i in range(k, k+diff_in_lines):
for i in range(k, k + diff_in_lines):
if lines[i] == '\n':
lines.pop(i-1)
lines.pop(i - 1)
break
elif i < len(lines) and ':' not in lines[i]:
lines.pop(i)
Expand Down

0 comments on commit 5f98078

Please sign in to comment.