| Home | Trees | Indices | Help |
|---|
|
|
object --+
|
basestring --+
|
str --+
|
path
Represents a filesystem path.
For documentation on individual methods, consult their counterparts in os.path.
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
| Return (p.parent, p.name) |
|
||
| Return (p.drive, <the rest of p>) |
|
||
| Return (p.stripext(), p.ext) |
|
||
| Remove one file extension from the path |
|
||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
| List of items in this directory |
|
||
| List of this directory's subdirectories |
|
||
| List of the files in this directory |
|
||
| iterator over files and subdirs, recursively |
|
||
| iterator over subdirs, recursively |
|
||
| iterator over files in D, recursively |
|
||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
Inherited from Inherited from Inherited from |
|||
|
|||
|
|||
|
|||
uncshare = property(_get_uncshare, None, None, """ The UNC mou
|
|||
|
|||
|
parent This path's parent directory, as a new path object. |
|||
|
name The name of this file or directory without the full path. |
|||
|
namebase The same as path.name, but with one file extension stripped off. |
|||
|
ext The file extension, for example '.py'. |
|||
|
drive The drive specifier, for example 'C:'. |
|||
|
atime Last access time of the file. |
|||
|
mtime Last-modified time of the file. |
|||
|
ctime Creation time of the file. |
|||
|
size Size of the file, in bytes. |
|||
|
owner Name of the owner of this file or directory. |
|||
|
Inherited from |
|||
|
|||
repr(x)
|
x+y
|
fp.__div__(rel) == fp / rel == fp.joinpath(rel) Join two path components, adding a separator character if needed. |
fp.__div__(rel) == fp / rel == fp.joinpath(rel) Join two path components, adding a separator character if needed. |
Clean up a filename by calling expandvars(), expanduser(), and normpath() on it. This is commonly everything needed to clean up a filename read from a configuration file, for example. |
Split the drive specifier from this path. If there is no drive specifier, p.drive is empty, so the return value is simply (path(''), p). This is always the case on Unix.
|
Split the filename extension from this path and return the two parts. Either part may be empty. The extension is everything from '.' to the end of the last path segment. This has the property that if (a, b) == p.splitext(), then a + b == p.
|
Join two or more path components, adding a separator character (os.sep) if needed. Returns a new path object. |
Return a list of the path components in this path. The first item in the list will be a path. Its value will be either os.curdir, os.pardir, empty, or the root directory of this path (for example, '/' or 'C:\\'). The other items in the list will be strings. path.path.joinpath(*result) will yield the original path. |
Return a relative path from self to dest. If there is no relative path from self to dest, for example if they reside on different drives in Windows, then this returns dest.abspath(). |
Use D.files() or D.dirs() instead if you want a listing of just files or just subdirectories. The elements of the list are path objects. With the optional 'pattern' argument, this only lists items whose names match the given pattern.
|
The elements of the list are path objects. This does not walk recursively into subdirectories (but see path.walkdirs). With the optional 'pattern' argument, this only lists directories whose names match the given pattern. For example, d.dirs('build-*').
|
The elements of the list are path objects. This does not walk into subdirectories (see path.walkfiles). With the optional 'pattern' argument, this only lists files whose names match the given pattern. For example, d.files('*.pyc').
|
The iterator yields path objects naming each child item of this directory and its descendants. This requires that D.isdir(). This performs a depth-first traversal of the directory tree. Each directory is returned just before all its children. The errors= keyword argument controls behavior when an error occurs. The default is 'strict', which causes an exception. The other allowed values are 'warn', which reports the error via warnings.warn(), and 'ignore'.
|
With the optional 'pattern' argument, this yields only directories whose names match the given pattern. For example, mydir.walkdirs('*test') yields only directories with names ending in 'test'. The errors= keyword argument controls behavior when an error occurs. The default is 'strict', which causes an exception. The other allowed values are 'warn', which reports the error via warnings.warn(), and 'ignore'.
|
The optional argument, pattern, limits the results to files with names that match the pattern. For example, mydir.walkfiles('*.tmp') yields only files with the .tmp extension.
|
Return True if self.name matches the given pattern.
|
Return a list of path objects that match the pattern.
|
Open this file. Return a file object. |
Open this file and write the given bytes to it. Default behavior is to overwrite any existing file. Call p.write_bytes(bytes, append=True) to append instead. |
Open this file, read it in, return the content as a string. This uses 'U' mode in Python 2.3 and later, so '\r\n' and '\r' are automatically translated to '\n'. Optional arguments:
|
Write the given text to this file. The default behavior is to overwrite any existing file; to append instead, use the 'append=True' keyword argument. There are two differences between path.write_text() and path.write_bytes(): newline handling and Unicode handling. See below. Parameters:
--- Newline handling. write_text() converts all standard end-of-line sequences ('\n', '\r', and '\r\n') to your platform's default end-of-line sequence (see os.linesep; on Windows, for example, the end-of-line marker is '\r\n'). If you don't like your platform's default, you can override it using the 'linesep=' keyword argument. If you specifically want write_text() to preserve the newlines as-is, use 'linesep=None'. This applies to Unicode text the same as to 8-bit text, except there are three additional standard Unicode end-of-line sequences: u'\x85', u'\r\x85', and u'\u2028'. (This is slightly different from when you open a file for writing with fopen(filename, "w") in C or file(filename, 'w') in Python.) --- Unicode If 'text' isn't Unicode, then apart from newline handling, the bytes are written verbatim to the file. The 'encoding' and 'errors' arguments are not used and must be omitted. If 'text' is Unicode, it is first converted to bytes using the specified 'encoding' (or the default encoding if 'encoding' isn't specified). The 'errors' argument applies only to this conversion. |
Open this file, read all lines, return them in a list. This uses 'U' mode in Python 2.3 and later.
|
Write the given lines of text to this file. By default this overwrites any existing file at this path. This puts a platform-specific newline sequence on every line. See 'linesep' below.
|
Calculate the md5 hash for this file. This reads through the entire file. |
Test whether a path exists. Returns False for broken symbolic links |
Return true if current user has access to this path. mode - One of the constants os.F_OK, os.R_OK, os.W_OK, os.X_OK |
Return the name of the owner of this file or directory. This follows symbolic links. On Windows, this returns a name of the form ur'DOMAIN\User Name'. On Windows, a group can own a file or directory. |
Set the access/modified times of this file to the current time. Create the file if it does not exist. |
Return the path to which this symbolic link points. The result may be an absolute or a relative path. |
Return the path to which this symbolic link points. The result is always an absolute path. |
Copy data and mode bits ("cp src dst"). The destination may be a directory. |
Copy data and all stat info ("cp -p src dst"). The destination may be a directory. |
Recursively copy a directory tree using copy2().
The destination directory must not already exist.
If exception(s) occur, an Error is raised with a list of reasons.
If the optional symlinks flag is true, symbolic links in the
source tree result in symbolic links in the destination tree; if
it is false, the contents of the files pointed to by symbolic
links are copied.
The optional ignore argument is a callable. If given, it
is called with the `src` parameter, which is the directory
being visited by copytree(), and `names` which is the list of
`src` contents, as returned by os.listdir():
callable(src, names) -> ignored_names
Since copytree() is called recursively, the callable will be
called once for each directory that is copied. It returns a
list of names relative to the `src` directory that should
not be copied.
XXX Consider this example code rather than the ultimate tool.
|
Recursively move a file or directory to another location. This is similar to the Unix "mv" command. If the destination is a directory or a symlink to a directory, the source is moved inside the directory. The destination path must not already exist. If the destination already exists but is not a directory, it may be overwritten depending on os.rename() semantics. If the destination is on our current filesystem, then rename() is used. Otherwise, src is copied to the destination and then removed. A lot more could be done here... A look at a mv.c shows a lot of the issues this implementation glosses over. |
Recursively delete a directory tree. If ignore_errors is set, errors are ignored; otherwise, if onerror is set, it is called to handle the error with arguments (func, path, exc_info) where func is os.listdir, os.remove, or os.rmdir; path is the argument to that function that caused it to fail; and exc_info is a tuple returned by sys.exc_info(). If ignore_errors is false and onerror is None, an exception is raised. |
|
|||
uncshare
|
|
|||
parentThis path's parent directory, as a new path object. For example, path('/usr/local/lib/libpython.so').parent == path('/usr/local/lib')
|
nameThe name of this file or directory without the full path. For example, path('/usr/local/lib/libpython.so').name == 'libpython.so'
|
namebaseThe same as path.name, but with one file extension stripped off. For example, path('/home/guido/python.tar.gz').name == 'python.tar.gz', but path('/home/guido/python.tar.gz').namebase == 'python.tar'
|
extThe file extension, for example '.py'.
|
driveThe drive specifier, for example 'C:'. This is always empty on systems that don't use drive specifiers.
|
atimeLast access time of the file.
|
mtimeLast-modified time of the file.
|
ctimeCreation time of the file.
|
sizeSize of the file, in bytes.
|
ownerName of the owner of this file or directory.
|
| Home | Trees | Indices | Help |
|---|
| Generated by Epydoc 3.0.1 on Sat Apr 17 20:45:14 2010 | http://epydoc.sourceforge.net |