Package qm :: Module label :: Class Label
[hide private]
[frames] | no frames]

Class Label

source code

Known Subclasses:

A 'Label' identifies an entity.

A 'Label' is a generalization of a filename. Like filenames, labels consist of one or more directories followed by a basename. However, the format used for a label need not be the same as that used by filenames.

Each label class defines a separator character to take the place of the '/' character used by many file systems.

All labels are relative labels; no label may begin with a separator character.

Instance Methods [hide private]
 
__init__(self, label)
Construct a new 'Label'.
source code
 
Join(self, *labels)
Combine this label and the 'labels' into a single label.
source code
 
Split(self)
Split the label into a pair '(directory, basename)'.
source code
 
SplitLeft(self)
Split the label into a pair '(parent, subpath)'.
source code
 
Basename(self)
Return the basename for the label.
source code
 
Dirname(self)
Return the directory name for the 'label'.
source code
 
IsValid(self, label, is_component)
Returns true if 'label' is valid.
source code
 
__str__(self)
Return the string form of this label.
source code
Method Details [hide private]

__init__(self, label)
(Constructor)

source code 

Construct a new 'Label'.

'label' -- A string giving the value of the label.

Join(self, *labels)

source code 

Combine this label and the 'labels' into a single label.

'labels' -- A sequence of strings giving the components of the new label. All but the last are taken as directory names; the last is treated as a basename.

Split(self)

source code 

Split the label into a pair '(directory, basename)'.

returns -- A pair '(directory, basename)', each of which is a label.

It is always true that 'directory.join(basename)' will return a label equivalent to the original label.

SplitLeft(self)

source code 

Split the label into a pair '(parent, subpath)'. This is the same operation as Split, except the split occurs at the leftmost separator, not the rightmost.

returns -- A pair '(directory, basename)', each of which is a label.

It is always true that 'directory.join(basename)' will return a label equivalent to the original label.

Basename(self)

source code 

Return the basename for the label.

returns -- A string giving the basename for the label. The value returned for 'l.basename()' is always the same as 'l.split()[1]'.

Dirname(self)

source code 

Return the directory name for the 'label'.

returns -- A string giving the directory name for the 'label'. The value returned for 'l.dirname()' is always the same as 'l.split()[0]'.

IsValid(self, label, is_component)

source code 

Returns true if 'label' is valid.

'label' -- The string being tested for validity.

'is_component' -- True if the string being tested is just a single component of a label path.

returns -- True if 'label' is not valid.