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

« back to all changes in this revision

Viewing changes to landscape/lib/tag.py

  • Committer: Andreas Hasenack
  • Date: 2011-05-05 14:12:15 UTC
  • Revision ID: andreas@canonical.com-20110505141215-5ymuyyh5es9pwa6p
Added hardy files.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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