HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //usr/lib/python3/dist-packages/landscape/lib/tag.py
import re


_tag_check = re.compile(r"^\w+[\w-]*$", re.UNICODE)


def is_valid_tag(tagname):
    """Return True if the tag meets our tag requirements."""
    return _tag_check.match(tagname)


def is_valid_tag_list(tag_list):
    """Validate a tag_list string.

    @param tag_list: string like london, server which will be split on the
    commas and each tag verified for validity.
    """
    if not tag_list:
        return True
    return all(is_valid_tag(tag.strip()) for tag in tag_list.split(","))