~ahasenack/landscape-client/landscape-client-11.02-0ubuntu0.8.04.1

1 by Andreas Hasenack
Added hardy files.
1
import re
2
3
_tag_check = re.compile("^\w+[\w-]*$", re.UNICODE)
4
5
def is_valid_tag(tagname):
6
    """Return True if the tag meets our tag requirements."""
7
    return _tag_check.match(tagname)
8
9
10
def is_valid_tag_list(tag_list):
11
    """Validate a tag_list string.
12
13
    @param tag_list: string like london, server which will be split on the
14
    commas and each tag verified for validity.
15
    """
16
    if tag_list:
17
        tags = [tag.strip() for tag in tag_list.split(",")]
18
        for tag in tags:
19
            if not is_valid_tag(tag):
20
                return False
21
    return True