home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Datafile PD-CD 5
/
DATAFILE_PDCD5.iso
/
utilities
/
p
/
python
/
pyhtmldoc
/
r
/
riscospath
< prev
next >
Wrap
Text File
|
1996-11-14
|
5KB
|
99 lines
<TITLE>riscospath -- Python library reference</TITLE>
Next: <A HREF="../s/swi" TYPE="Next">swi</A>
Prev: <A HREF="../r/riscos" TYPE="Prev">riscos</A>
Up: <A HREF="../r/riscos_only" TYPE="Up">RISCOS ONLY</A>
Top: <A HREF="../t/top" TYPE="Top">Top</A>
<H1>13.2. Standard Module <CODE>riscospath</CODE></H1>
This module implements some useful functions on RiscOS pathnames.
<P>
<B>Do not import this module directly.</B> Instead, import the
module <CODE>os</CODE> and use <CODE>os.path</CODE>.
<DL><DT><B>basename</B> (<VAR>p</VAR>) -- function of module riscospath<DD>
Return the base name of pathname
<VAR>p</VAR>.
This is the second half of the pair returned by
<CODE>riscospath.split(<VAR>p</VAR>)</CODE>.
</DL>
<DL><DT><B>commonprefix</B> (<VAR>list</VAR>) -- function of module riscospath<DD>
Return the longest string that is a prefix of all strings in
<VAR>list</VAR>.
If
<VAR>list</VAR>
is empty, return the empty string (<CODE>''</CODE>).
</DL>
<DL><DT><B>exists</B> (<VAR>p</VAR>) -- function of module riscospath<DD>
Return true if
<VAR>p</VAR>
refers to an existing path.
</DL>
<DL><DT><B>expandvars</B> (<VAR>p</VAR>) -- function of module riscospath<DD>
Return the argument with environment variables expanded. Substrings
of the form `<SAMP>$<VAR>name</VAR></SAMP>' or `<SAMP>${<VAR>name</VAR>}</SAMP>' are
replaced by the value of environment variable <VAR>name</VAR>. Malformed
variable names and references to non-existing variables are left
unchanged.
</DL>
<DL><DT><B>isabs</B> (<VAR>p</VAR>) -- function of module riscospath<DD>
Return true if <VAR>p</VAR> is an absolute pathname (has a dollar).
</DL>
<DL><DT><B>isfile</B> (<VAR>p</VAR>) -- function of module riscospath<DD>
Return true if <VAR>p</VAR> is an existing file. This includes image files.
</DL>
<DL><DT><B>isdir</B> (<VAR>p</VAR>) -- function of module riscospath<DD>
Return true if <VAR>p</VAR> is an existing directory. This includes image files.
</DL>
<DL><DT><B>islink</B> (<VAR>p</VAR>) -- function of module riscospath<DD>
Always returns false.
</DL>
<DL><DT><B>join</B> (<VAR>p</VAR>, <VAR>q</VAR>) -- function of module riscospath<DD>
Join the paths
<VAR>p</VAR>
and
<VAR>q</VAR> intelligently:
If
<VAR>q</VAR>
is an absolute path, the return value is
<VAR>q</VAR>.
Otherwise, the concatenation of
<VAR>p</VAR>
and
<VAR>q</VAR>
is returned, with a full stop (<CODE>'.'</CODE>) inserted unless
<VAR>p</VAR>
is empty or ends in a slash.
</DL>
<DL><DT><B>normcase</B> (<VAR>p</VAR>) -- function of module riscospath<DD>
Normalize the case of a pathname. This converts upper case to
lower case.
</DL>
<DL><DT><B>split</B> (<VAR>p</VAR>) -- function of module riscospath<DD>
Split the pathname <VAR>p</VAR> in a pair <CODE>(<VAR>head</VAR>, <VAR>tail</VAR>)</CODE>,
where <VAR>tail</VAR> is the last pathname component and <VAR>head</VAR> is
everything leading up to that. The <VAR>tail</VAR> part will never contain
a full stop; if <VAR>p</VAR> ends in a full stop, <VAR>tail</VAR> will be empty. If
there is no full stop in <VAR>p</VAR>, <VAR>head</VAR> will be empty. If <VAR>p</VAR> is
empty, both <VAR>head</VAR> and <VAR>tail</VAR> are empty. Trailing full stops are
stripped from <VAR>head</VAR> unless it is the root.
In nearly all cases, <CODE>join(<VAR>head</VAR>, <VAR>tail</VAR>)</CODE>
equals <VAR>p</VAR>.
</DL>
<DL><DT><B>splitext</B> (<VAR>p</VAR>) -- function of module riscospath<DD>
Split the pathname <VAR>p</VAR> in a pair <CODE>(<VAR>root</VAR>, <VAR>ext</VAR>)</CODE>
such that <CODE><VAR>root</VAR> + <VAR>ext</VAR> == <VAR>p</VAR></CODE>,
the last component of <VAR>root</VAR> contains no slashess,
and <VAR>ext</VAR> is empty or begins with a slash.
</DL>
<DL><DT><B>walk</B> (<VAR>p</VAR>, <VAR>visit</VAR>, <VAR>arg</VAR>) -- function of module riscospath<DD>
Calls the function <VAR>visit</VAR> with arguments
<CODE>(<VAR>arg</VAR>, <VAR>dirname</VAR>, <VAR>names</VAR>)</CODE> for each directory in the
directory tree rooted at <VAR>p</VAR> (including <VAR>p</VAR> itself, if it is a
directory). The argument <VAR>dirname</VAR> specifies the visited directory,
the argument <VAR>names</VAR> lists the files in the directory (gotten from
<CODE>riscos.listdir(<VAR>dirname</VAR>)</CODE>.
The <VAR>visit</VAR> function may modify <VAR>names</VAR> to
influence the set of directories visited below <VAR>dirname</VAR>, e.g., to
avoid visiting certain parts of the tree. (The object referred to by
<VAR>names</VAR> must be modified in place, using <CODE>del</CODE> or slice
assignment.)
</DL>