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.
Methods
|
|
Basename
Dirname
IsValid
Join
Split
SplitLeft
__init__
__str__
|
|
Basename
|
Basename ( self )
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
|
Dirname ( self )
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
|
IsValid (
self,
label,
is_component,
)
Returns true if label is not 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.
|
|
Join
|
Join ( self, *labels )
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
|
Split ( self )
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
|
SplitLeft ( self )
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.
|
|
__init__
|
__init__ ( self, label )
Construct a new Label .
-
label
- A string giving the value of the label.
|
|
__str__
|
__str__ ( self )
Return the string form of this label.
|
|