Skip to content

Commit b671b0b

Browse files
committed
improve comments
Signed-off-by: Zen <[email protected]>
1 parent 4ef461e commit b671b0b

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/ugrd/initramfs_generator.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -159,14 +159,14 @@ def sort_hook_functions(self, hook: str) -> None:
159159
return self.logger.debug("No import order specified for hook: %s" % hook)
160160

161161
def iter_order(order, direction):
162-
# Iterate over all before/after functions
163-
# If the function is not in the correct position, move it
164-
# Use the index of the function to determine the position
165-
# Move the function in the imports list as well
162+
""" Iterate over all functions in an import order list,
163+
using this information to move the order of function names in the import list.
164+
165+
Returns True if any changes were made, False otherwise."""
166166
changed = False
167167

168168
for func_name, other_funcs in order.items():
169-
func_index = func_names.index(func_name)
169+
func_index = func_names.index(func_name) # Get the index based on the current position
170170
assert func_index >= 0, "Function not found in import list: %s" % func_name
171171
for other_func in other_funcs:
172172
try:
@@ -210,12 +210,13 @@ def reorder_func(direction):
210210
iterations = max_iterations
211211
while iterations:
212212
iterations -= 1
213+
# Update the order based on the before and after lists
213214
if not any([iter_order(before, "before"), iter_order(after, "after")]):
214215
self.logger.debug(
215216
"[%s] Import order converged after %s iterations" % (hook, max_iterations - iterations)
216217
)
217218
break # Keep going until no changes are made
218-
else:
219+
else: # If the loop completes without breaking, raise an error
219220
self.logger.error("Import list: %s" % func_names)
220221
self.logger.error("Before: %s" % before)
221222
self.logger.error("After: %s" % after)

0 commit comments

Comments
 (0)