Package qm :: Package test :: Package classes :: Module file_label
[hide private]
[frames] | no frames]

Source Code for Module qm.test.classes.file_label

 1  ######################################################################## 
 2  # 
 3  # File:   file_label.py 
 4  # Author: Mark Mitchell 
 5  # Date:   06/11/2002 
 6  # 
 7  # Contents: 
 8  #   FileLabel 
 9  # 
10  # Copyright (c) 2002 by CodeSourcery, LLC.  All rights reserved.  
11  # 
12  ######################################################################## 
13   
14  ######################################################################## 
15  # Imports 
16  ######################################################################## 
17   
18  from   qm.label   import * 
19  import os 
20  import re 
21   
22  ######################################################################## 
23  # Classes 
24  ######################################################################## 
25   
26 -class FileLabel(Label):
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
47 - def Split(self):
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
59 - def Basename(self):
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
69 - def Dirname(self):
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