Provide a common set of path management functions.
Many of the os.path functions are fronted by functions here to allow
for tracing and consistent use of those functions.
Imported modules
|
|
from StreamFlushTest import StreamFlushTest
import glob
import os
import string
import sys
from trace import trace
import unittest
|
Functions
|
|
|
|
applyPrefixToPath
|
applyPrefixToPath ( path, prefix )
Add the prefix value to every part of a given path.
|
|
basename
|
basename ( f )
os.path.basename
|
|
commonPrefix
|
commonPrefix ( path1, path2 )
Find parts of path1 and path2 at the beginning of each which are the same.
Arguments
- path1
- A filesystem path.
- path2
- A filesystem path.
Returns a string containing the full path which occurs at the
beginning of both path1 and path2.
This function differs from os.path.commonprefix in that a part of
the path is considered the same only if the full directory or
subdirectory name matches.
|
|
computeRelativeHTMLLink
|
computeRelativeHTMLLink (
fromName,
toName,
baseDirectory,
)
Compute the relative link between fromName and toName.
Parameters
-
fromName
- Named output node from which to compute the link.
-
toName
- Named output node to which link should point.
-
baseDirectory
- Name of the base directory in which both
fromName and toName will reside.
Both fromName and toName are strings refering to URL targets.
This method computes the relative positions of the two nodes
and returns a string which, if used as the HREF in a link in
fromName will point directly to toName.
|
|
cwd
|
cwd ()
os.getcwd
|
|
dirname
|
dirname ( f )
os.path.dirname
|
|
exists
|
exists ( f )
os.path.exists
|
|
findFilesInDir
|
findFilesInDir ( directoryName, filenamePattern='*' )
Find all files in the directory which match the glob pattern.
Parameters
- directoryName
- String containing the name of a directory on
the file system.
- filenamePattern
- String containing a regular expression to be
used by the glob module for matching when looking for files in
directoryName .
|
|
isSomethingThatLooksLikeDirectory
|
isSomethingThatLooksLikeDirectory ( path )
|
|
isdir
|
isdir ( f )
os.path.isdir
|
|
join
|
join ( *args )
os.path.join
os.path functions
|
|
joinWithCommonMiddle
|
joinWithCommonMiddle (
path1prefix,
path1,
path2,
)
Join path1 and path2.
Arguments
- path1prefix
- Beginning of path1 which should be ignored for
comparisons between path1 and path2.
- path1
- First path to join.
- path2
- Second path to join, may have part of path1 after
path1prefix.
This function is a bit weird. The result of:
joinWithCommonMiddle('/root/one', '/root/one/two', 'two/three/filename.txt')
is:
/root/one/two/three/filename.txt
|
|
normpath
|
normpath ( p )
os.path.normpath
|
|
removePrefix
|
removePrefix ( path, prefix )
Remove prefix from the beginning of path, if present.
|
|
removeRelativePrefix
|
removeRelativePrefix ( filename )
Remove './', ../ , etc. from the front of filename.
Returns a new string, unless no changes are made.
|
|
rmkdir
|
rmkdir ( path )
Create a directory and all of its children.
|
|
split
|
split ( f )
os.path.split
|
|
splitext
|
splitext ( f )
os.path.splitext
|
Classes
|
|
|