MCPcopy
hub / github.com/saltstack/salt / _apply_exclude

Function _apply_exclude

salt/state.py:354–392  ·  view source on GitHub ↗

Read in the __exclude__ list and remove all excluded objects from the high data

(high: HighData)

Source from the content-addressed store, hash-verified

352
353
354def _apply_exclude(high: HighData) -> HighData:
355 """
356 Read in the __exclude__ list and remove all excluded objects from the
357 high data
358 """
359 if "__exclude__" not in high:
360 return high
361 ex_sls = set()
362 ex_id = set()
363 exclude = high.pop("__exclude__")
364 for exc in exclude:
365 if isinstance(exc, str):
366 # The exclude statement is a string, assume it is an sls
367 ex_sls.add(exc)
368 if isinstance(exc, dict):
369 # Explicitly declared exclude
370 if len(exc) != 1:
371 continue
372 key = next(iter(exc.keys()))
373 if key == "sls":
374 ex_sls.add(exc["sls"])
375 elif key == "id":
376 ex_id.add(exc["id"])
377 # Now the excludes have been simplified, use them
378 if ex_sls:
379 # There are sls excludes, find the associated ids
380 for name, body in high.items():
381 if name.startswith("__"):
382 continue
383 sls = body.get("__sls__", "")
384 if not sls:
385 continue
386 for ex_ in ex_sls:
387 if fnmatch.fnmatch(sls, ex_):
388 ex_id.add(name)
389 for id_ in ex_id:
390 if id_ in high:
391 high.pop(id_)
392 return high
393
394
395def _verify_high(high: dict) -> list[str]:

Callers 2

apply_excludeMethod · 0.85
apply_excludeMethod · 0.85

Calls 6

setFunction · 0.50
popMethod · 0.45
addMethod · 0.45
keysMethod · 0.45
itemsMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected