1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 from qm.label import *
19 import os
20 import re
21
22
23
24
25
27 """A 'FileLabel' is a 'Label' that uses the filesystem's naming scheme.
28
29 A 'FileLabel' is a 'Label' whose separator character is the
30 operating system's file system separator character (typically '/' or
31 '\\'). These labels are not system-independent; there is no
32 guarantee that 'FileLabel's will have the same meaning on different
33 operating systems."""
34
35 _sep = os.sep
36
37 - def Join(self, *labels):
38 """Combine this label and the 'labels' into a single label.
39
40 'labels' -- A sequence of strings giving the components of the
41 new label. All but the last are taken as directory names; the
42 last is treated as a basename."""
43
44 return self.__class__(apply(os.path.join, (self._label,) + labels))
45
46
48 """Split the label into a pair '(directory, basename)'.
49
50 returns -- A pair '(directory, basename)', each of which is
51 a label.
52
53 It is always true that 'directory.join(basename)' will return a
54 label equivalent to the original label."""
55
56 return os.path.split(self._label)
57
58
60 """Return the basename for the label.
61
62 returns -- A string giving the basename for the label. The
63 value returned for 'l.basename()' is always the same as
64 'l.split()[1]'."""
65
66 return os.path.basename(self._label)
67
68
70 """Return the directory name for the 'label'.
71
72 returns -- A string giving the directory name for the 'label'.
73 The value returned for 'l.dirname()' is always the same as
74 'l.split()[0]'."""
75
76 return os.path.dirname(self._label)
77