Skip to content

Commit 5fc8884

Browse files
committed
build: sort.py: rename line variables
Rename `line` to `original_line` to make it less likely to accidentally read from/write to it instead of the fixed line. Rename `fixed_line` to `line` to make the code shorter since it is now referenced much more often (up to 3 times in the same line of code) than the original line. See also commit aa17ca5 ("sort.py: rename protocols to original_protocols", 2022-10-17) / PR netblue30#5429.
1 parent a0fb8af commit 5fc8884

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

contrib/sort.py

+16-16
Original file line numberDiff line numberDiff line change
@@ -70,25 +70,25 @@ def check_profile(filename, overwrite):
7070
lines = profile.read().split("\n")
7171
was_fixed = False
7272
fixed_profile = []
73-
for lineno, line in enumerate(lines, 1):
74-
fixed_line = line
75-
if fixed_line[:12] in ("private-bin ", "private-etc ", "private-lib "):
76-
fixed_line = f"{fixed_line[:12]}{sort_alphabetical(fixed_line[12:])}"
77-
elif fixed_line[:13] in ("seccomp.drop ", "seccomp.keep "):
78-
fixed_line = f"{fixed_line[:13]}{sort_alphabetical(fixed_line[13:])}"
79-
elif fixed_line[:10] in ("caps.drop ", "caps.keep "):
80-
fixed_line = f"{fixed_line[:10]}{sort_alphabetical(fixed_line[10:])}"
81-
elif fixed_line[:8] == "protocol":
82-
fixed_line = f"protocol {sort_protocol(fixed_line[9:])}"
83-
elif fixed_line[:8] == "seccomp ":
84-
fixed_line = f"{fixed_line[:8]}{sort_alphabetical(fixed_line[8:])}"
85-
if fixed_line != line:
73+
for lineno, original_line in enumerate(lines, 1):
74+
line = original_line
75+
if line[:12] in ("private-bin ", "private-etc ", "private-lib "):
76+
line = f"{line[:12]}{sort_alphabetical(line[12:])}"
77+
elif line[:13] in ("seccomp.drop ", "seccomp.keep "):
78+
line = f"{line[:13]}{sort_alphabetical(line[13:])}"
79+
elif line[:10] in ("caps.drop ", "caps.keep "):
80+
line = f"{line[:10]}{sort_alphabetical(line[10:])}"
81+
elif line[:8] == "protocol":
82+
line = f"protocol {sort_protocol(line[9:])}"
83+
elif line[:8] == "seccomp ":
84+
line = f"{line[:8]}{sort_alphabetical(line[8:])}"
85+
if line != original_line:
8686
was_fixed = True
8787
print(
88-
f"{filename}:{lineno}:-{line}\n"
89-
f"{filename}:{lineno}:+{fixed_line}"
88+
f"{filename}:{lineno}:-{original_line}\n"
89+
f"{filename}:{lineno}:+{line}"
9090
)
91-
fixed_profile.append(fixed_line)
91+
fixed_profile.append(line)
9292

9393
if was_fixed:
9494
if overwrite:

0 commit comments

Comments
 (0)