The pattern.py module#
Summary#
Return |
|
Return every entry in |
Description#
Wildcard/pattern helpers for named-object selection.
PyFluent accepts glob-style patterns on string indexers and string-list
properties (such as cell_zone_conditions.copy(from_="cell_1", to="cell_*")
and zone_assignment.passive_zone = "*bar*|*tabzone*"). The solver itself
expands these patterns at runtime. This module mirrors that contract on
the client side to do the following:
Recognize a pattern in user- or host-supplied identifiers.
Validate a pattern by checking that it matches at least one live name.
Enumerate matching names for batched (multi-edit) plan steps.
The pattern grammar is a subset of PyFluent’s:
*: Match any run of characters (fnmatchsemantics).?: Match a single character.[abc]: Character class.|: Alternation between sub-patterns. For example,"wall-*|inlet-?"matches either branch.
Plain identifiers (no wildcard metacharacters) are returned by
expand_pattern() unchanged when they appear in candidates,
so a literal name behaves as a direct lookup.
Module detail#
- pattern.is_pattern(name: str | None) bool#
Return
Truewhennamecontains any wildcard metacharacter.
- pattern.expand_pattern(pattern: str, candidates: Iterable[str]) list[str]#
Return every entry in
candidatesmatchingpattern.The result preserves the order in which candidates first match, so callers get a stable enumeration that mirrors the underlying live name list. Duplicate matches (possible across alternation branches) are collapsed.
Plain (non-pattern)
patternvalues fall through to a literal membership check, returning[pattern]if present and[]otherwise.