diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-26 06:24:58 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-26 06:24:58 +0000 |
commit | ba233a0cbad76b4783a03893e7bf4716fbc0f0ec (patch) | |
tree | ad369728c1edbe3631c8150585659078ae5d7d0b /src/ansiblelint/text.py | |
parent | Releasing progress-linux version 6.17.2-3~progress7.99u1. (diff) | |
download | ansible-lint-ba233a0cbad76b4783a03893e7bf4716fbc0f0ec.tar.xz ansible-lint-ba233a0cbad76b4783a03893e7bf4716fbc0f0ec.zip |
Merging upstream version 24.6.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | src/ansiblelint/text.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/ansiblelint/text.py b/src/ansiblelint/text.py index 038fde1..3510f75 100644 --- a/src/ansiblelint/text.py +++ b/src/ansiblelint/text.py @@ -1,4 +1,5 @@ """Text utils.""" + from __future__ import annotations import re @@ -6,6 +7,7 @@ from functools import cache RE_HAS_JINJA = re.compile(r"{[{%#].*[%#}]}", re.DOTALL) RE_HAS_GLOB = re.compile("[][*?]") +RE_IS_FQCN_OR_NAME = re.compile(r"^\w+(\.\w+\.\w+)?$") def strip_ansi_escape(data: str | bytes) -> str: @@ -47,3 +49,9 @@ def has_jinja(value: str) -> bool: def has_glob(value: str) -> bool: """Return true if a string looks like having a glob pattern.""" return bool(isinstance(value, str) and RE_HAS_GLOB.search(value)) + + +@cache +def is_fqcn_or_name(value: str) -> bool: + """Return true if a string seems to be a module/filter old name or a fully qualified one.""" + return bool(isinstance(value, str) and RE_IS_FQCN_OR_NAME.search(value)) |