The ``pattern.py`` module ========================= .. py:module:: ansys.fluent.mcp.solve.lib.pattern Summary ------- .. py:currentmodule:: pattern .. tab-set:: .. tab-item:: Functions .. list-table:: :header-rows: 0 :widths: auto * - :py:obj:`~is_pattern` - Return ``True`` when ``name`` contains any wildcard metacharacter. * - :py:obj:`~expand_pattern` - Return every entry in ``candidates`` matching ``pattern``. 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 (``fnmatch`` semantics). * ``?``: 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 :func:`expand_pattern` unchanged when they appear in ``candidates``, so a literal name behaves as a direct lookup. .. !! processed by numpydoc !! Module detail ------------- .. py:function:: is_pattern(name: str | None) -> bool Return ``True`` when ``name`` contains any wildcard metacharacter. :Parameters: **name** : :class:`python:str` | :data:`python:None` Name of the object, module, or setting being processed. :Returns: :ref:`bool ` Boolean result produced by the function. .. !! processed by numpydoc !! .. py:function:: expand_pattern(pattern: str, candidates: Iterable[str]) -> list[str] Return every entry in ``candidates`` matching ``pattern``. 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) ``pattern`` values fall through to a literal membership check, returning ``[pattern]`` if present and ``[]`` otherwise. :Parameters: **pattern** : :class:`python:str` Selection pattern for matching object names. **candidates** : :obj:`Iterable`\[:class:`python:str`] Candidates to supply to the function. :Returns: :class:`python:list`\[:class:`python:str`] Collection containing the operation results. .. !! processed by numpydoc !!