refactoring and improvement, sort_env_files_by_rule now passes more complex test case
This commit is contained in:
parent
2e988c6150
commit
dc50a9d6f7
1 changed files with 3 additions and 7 deletions
|
|
@ -36,17 +36,13 @@ def is_rule_satisfied(in_list: list[EnvFile], rule: DependencyRule, swap=False)
|
|||
|
||||
child_indices = _get_indices_with_string(in_list, rule.child)
|
||||
parent_indices = _get_indices_with_string(in_list, rule.dependency)
|
||||
child_index = min(child_indices)
|
||||
results: list[bool] = []
|
||||
for child_index in child_indices:
|
||||
for parent_index in parent_indices:
|
||||
if parent_index < child_index:
|
||||
results.append(True)
|
||||
else:
|
||||
if not parent_index < child_index:
|
||||
if swap:
|
||||
_swap_item_with_previous(in_list, parent_index)
|
||||
results.append(False)
|
||||
return all(results)
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
def sort_env_files_by_rule(env_list: list[EnvFile], rules: list[DependencyRule]) -> list[EnvFile]:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue