Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix docstrings of regex template filters #3011

Merged
merged 2 commits into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion tests/integration/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from requre.helpers.guess_object import Guess
from requre.helpers.requests_response import RequestResponseHandling

import tmt.utils
import tmt.utils.git
happz marked this conversation as resolved.
Show resolved Hide resolved

nitrate.set_cache_level(nitrate.CACHE_NONE)
Expand Down
28 changes: 14 additions & 14 deletions tmt/utils/templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ def _template_filter_match( # type: ignore[reportUnusedFunction,unused-ignore]
{{ 'foo/bar' | match('foo/.*').group() }}

# 'foo/bar' -> ''
{{ 'foo/bar' | regex_match('foo/(.+?)/(.*)') }}
{{ 'foo/bar' | match('foo/(.+?)/(.*)') }}

# 'foo/bar/baz' -> 'bar'
{{ 'foo/bar' | regex_match('foo/(.+?)/.*').group(1) }}
{{ 'foo/bar' | match('foo/(.+?)/.*').group(1) }}
"""

return re.match(pattern, s)
Expand All @@ -79,14 +79,14 @@ def _template_filter_search( # type: ignore[reportUnusedFunction,unused-ignore]

.. code-block:: jinja

# ' foo/bar' -> 'foo/bar'
{{ ' foo/bar' | match('foo/.*').group() }}
# 'baz/foo/bar' -> 'foo/bar'
{{ 'baz/foo/bar' | search('foo/.*').group() }}

# ' foo/bar' -> ''
{{ ' foo/bar' | regex_match('foo/(.+?)/(.*)') }}
# 'baz/foo/bar' -> ''
{{ 'baz/foo/bar' | search('foo/(.+?)/(.*)') }}

# ' foo/bar/baz' -> 'bar'
{{ ' foo/bar' | regex_match('foo/(.+?)/.*').group(1) }}
# 'baz/foo/bar/baz' -> 'bar'
{{ 'baz/foo/bar' | search('foo/(.+?)/.*').group(1) }}
"""

return re.search(pattern, s)
Expand Down Expand Up @@ -165,14 +165,14 @@ def _template_filter_regex_search( # type: ignore[reportUnusedFunction,unused-i

.. code-block:: jinja

# ' foo/bar' -> 'foo/bar'
{{ ' foo/bar' | regex_search('foo/.*') }}
# 'baz/foo/bar' -> 'foo/bar'
{{ 'baz/foo/bar' | regex_search('foo/.*') }}

# ' foo/bar' -> ''
{{ ' foo/bar' | regex_search('foo/(.+?)/(.*)') }}
# 'baz/foo/bar' -> ''
{{ 'baz/foo/bar' | regex_search('foo/(.+?)/(.*)') }}

# ' foo/bar/baz' -> 'bar'
{{ ' foo/bar/baz' | regex_search('foo/(.+?)/.*') }}
# 'baz/foo/bar/baz' -> 'bar'
{{ 'baz/foo/bar/baz' | regex_search('foo/(.+?)/.*') }}
"""

match = re.search(pattern, s)
Expand Down
Loading