diff options
Diffstat (limited to 'mailrules.py')
| -rwxr-xr-x | mailrules.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/mailrules.py b/mailrules.py index 26ed698..7df1b42 100755 --- a/mailrules.py +++ b/mailrules.py @@ -125,6 +125,17 @@ def load(path=None): return store +def ordered(rules): + """Enabled rules in execution order: by stage ascending, ties by position. + + `sorted` is stable, so sorting on stage alone preserves file order within + a stage. That is the tie-break the format promises, and it is why this + does not sort on (stage, id): an id-sorted tie would reorder rules a user + deliberately sequenced. + """ + return sorted([r for r in rules if r.enabled], key=lambda r: r.stage) + + def _parse_rule(obj, index, seen, warnings): """One rule, or None with a warning appended. `index` names the rule when it has no usable id of its own.""" |
