File size: 770 Bytes
8d48081
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
from typing import List, Dict, Any

def apply_rules(candidates: List[Dict[str, Any]], require_approvals: str = "", avoid_invasive: bool = False) -> List[Dict[str, Any]]:
    req = {t.strip().upper() for t in require_approvals.replace(";", ",").split(",") if t.strip()}
    out = []
    for d in candidates:
        if avoid_invasive and d.get("invasiveness","").lower() == "invasive":
            continue
        if req:
            dev_apps = {t.strip().upper() for t in str(d.get("approvals","")).replace(";", ",").split(",") if t.strip()}
            # OLD (AND): if not req.issubset(dev_apps): continue
            # NEW (OR) — pass if there is any overlap:
            if req.isdisjoint(dev_apps):
                continue
        out.append(d)
    return out