1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 from qm.label import *
19 import re
20
21
22
23
24
26 """A 'PythonLabel' is a 'Label' that uses the 'a.b.c' naming scheme.
27
28 A 'PythonLabel' is a 'Label' whose separator character is the period
29 and whose components consist of lower-case letters, numerals, and
30 underscores. These labels have the property that they can be easily
31 mapped to filenames on most operating systems; all valid labels are
32 valid filenames (replacing '.' with '/') and two different labels
33 will always map to two different filenames."""
34
35 _sep = '.'
36 """The separator character used to separate components."""
37
38 __valid_label_regexp = re.compile("[-a-z0-9_%s]+$" % _sep)
39 """A compiled regular expression that matches valid labels."""
40
41 - def IsValid(self, label, is_component):
42 """Returns true if this label is not valid.
43
44 returns -- True if this label is not valid."""
45
46 if not Label.IsValid(self, label, is_component):
47
48
49 return 0
50 elif not self.__valid_label_regexp.match(label):
51
52 return 0
53
54 return 1
55