dqm_ml_core.utils.matching
Wildcard pattern matching utilities for config field resolution.
Provides fnmatch-based expansion of include / exclude patterns
against a list of available strings (column names, split values, etc.).
has_pattern(s: str) -> bool
Return True if the string contains any fnmatch wildcard character.
resolve_include_exclude(include: list[str] | None, exclude: list[str] | None, available: list[str]) -> list[str]
Resolve (include, exclude) pattern lists against available strings.
- If include is
None, every item in available is a candidate. Otherwise, include patterns are expanded via :func:resolve_patterns. - Any candidate matching an exclude pattern is removed (exact match
for literal strings,
fnmatch.filterfor wildcard patterns).
Parameters
include:
Include patterns (None = all).
exclude:
Exclude patterns (None = nothing excluded).
available:
The set of concrete strings to match against.
Returns
The filtered list (order preserved).
Source code in packages/dqm-ml-core/src/dqm_ml_core/utils/matching.py
resolve_patterns(patterns: list[str], available: list[str]) -> list[str]
Expand patterns against available strings using fnmatch.
Literal (non-wildcard) patterns are emitted as-is. Wildcard patterns
are matched against available via fnmatch.filter. Order from
patterns is preserved (first occurrence wins) and duplicates are
removed.
Parameters
patterns:
List of patterns that may contain *, ? or [...].
available:
The set of concrete strings to match against.
Returns
A deduplicated, ordered list of matching concrete strings.