summaryrefslogtreecommitdiffstats
path: root/src/ansiblelint/text.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-26 06:24:57 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-26 06:24:57 +0000
commit1faea9a6c75f33109e8f66b57b432fdad57b3f46 (patch)
tree4184ce38ac0cf9d5a46bbbae03c87be82927f12b /src/ansiblelint/text.py
parentAdding upstream version 6.17.2. (diff)
downloadansible-lint-1faea9a6c75f33109e8f66b57b432fdad57b3f46.tar.xz
ansible-lint-1faea9a6c75f33109e8f66b57b432fdad57b3f46.zip
Adding upstream version 24.6.1.upstream/24.6.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--src/ansiblelint/text.py8
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))