Trees | Indices | Help |
|
---|
|
object --+ | AbstractFilePath --+ | FilePath
I am a path on the filesystem that only permits 'downwards' access.
Instantiate me with a pathname (for example, FilePath('/home/myuser/public_html')) and I will attempt to only provide access to files which reside inside that path. I may be a path to a file, a directory, or a file which does not exist.
The correct way to use me is to instantiate me, and then do ALL filesystem access through me. In other words, do not import the 'os' module; if you need to open a file, call my 'open' method. If you need to list a directory, call my 'path' method.
Even if you pass me a relative path, I will convert that to an absolute path internally.
Note: although time-related methods do return floating-point results,
they may still be only second resolution depending on the platform and
the last value passed to os.stat_float_times
.
If you want greater-than-second precision, call
os.stat_float_times(True)
, or use Python 2.5.
Greater-than-second precision is only available in Windows on Python2.5
and later.
Nested Classes | |
clonePath I am a path on the filesystem that only permits 'downwards' access. |
Instance Methods | |||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
file
|
|
||
|
|||
|
|||
|
|||
|
|||
float |
|
||
float |
|
||
float |
|
||
long
|
|
||
long
|
|
||
int
|
|
||
int
|
|
||
int
|
|
||
Permissions
|
|
||
bool
|
|
||
|
|||
|
|||
bool
|
|
||
bool
|
|
||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
str
|
|
||
str
|
|
||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
FilePath
|
|
||
|
|||
|
|||
|
|||
Inherited from Inherited from |
Class Variables | |
sep =
|
|
__implemented__ = <implementedBy twisted.python.filepath.FileP
|
Instance Variables | |
int or types.NoneType or os.stat_result
|
statinfo = None The currently cached status information about the file on the filesystem that this FilePath points to.
|
str
|
path = None The path from which 'downward' traversal is permitted. |
bool
|
alwaysCreate When opening this file, only succeed if the file does not already exist. |
Properties | |
Inherited from |
Method Details |
Convert a path string to an absolute path if necessary and initialize
the
|
Create and return a new
|
Use me if `path' might have slashes in it, but you know they're safe. (NOT slashes at the beginning. It still needs to be a _child_). |
Return my first existing child with a name in 'paths'. paths is expected to be a list of *pre-secured* path fragments; in most cases this will be specified by a system administrator and not an arbitrary user. If no appropriately-named children exist, this will return None. |
Attempt to return a path with my name, given multiple possible extensions. Each extension in exts will be tested and the first path which exists will be returned. If no path exists, None will be returned. If '' is in exts, then if the file referred to by this path exists, 'self' will be returned. The extension '*' has a magic meaning, which means "any path that begins with self.path+'.' is acceptable". |
Returns the absolute target as a FilePath if self is a link, self otherwise. The absolute link is the ultimate file or directory the link refers to (for instance, if the link refers to another link, and another...). If the filesystem does not support symlinks, or if the link is cyclical, raises a LinkError. Behaves like
|
Creates a symlink to self to at the path in the
|
Open this file using In all cases the file is opened in binary mode, so it is not necessary
to include
|
Re-calculate cached effects of 'stat'. To refresh information on this path after you know the filesystem may have changed, call this method.
|
Clear any cached information about the state of this path on disk. Since: 10.1.0 |
Changes the permissions on self, if possible. Propagates errors from
|
Retrieve the time of last access from this file.
|
Retrieve the time of the last status change for this file.
|
Retrieve the time that this file was last accessed.
|
Retrieve the file serial number, also called inode number, which distinguishes this file from all other files on the same device.
Since: 11.0 |
Retrieves the device containing the file. The inode number and device number together uniquely identify the file, but the device number is not necessarily consistent across reboots or system crashes.
Since: 11.0 |
Retrieves the number of hard links to the file. This count keeps track of how many directories have entries for this file. If the count is ever decremented to zero then the file itself is discarded as soon as no process still holds it open. Symbolic links are not counted in the total.
Since: 11.0 |
Returns the user ID of the file's owner.
Since: 11.0 |
Returns the group ID of the file.
Since: 11.0 |
Returns the permissions of the file. Should also work on Windows, however, those permissions may not what is expected in Windows.
Since: 11.1 |
Check if this
|
|
|
Returns whether the underlying path is a block device.
Since: 11.1 |
Returns whether the underlying path is a socket.
Since: 11.1 |
|
|
List the base names of the direct children of this
|
|
repr(x)
|
Updates the access and last modification times of the file at this file path to the current time. Also creates the file if it does not already exist.
|
Removes the file or directory that is represented by self. If
|
|
|
|
Replace the file at this path with a new file that contains the given bytes, trying to avoid data-loss in the meanwhile. On UNIX-like platforms, this method does its best to ensure that by the time this method returns, either the old contents or the new contents of the file will be present at this path for subsequent readers regardless of premature device removal, program crash, or power loss, making the following assumptions:
On most versions of Windows there is no atomic This method should be safe for use by multiple concurrent processes, but note that it is not easy to predict which process's contents will ultimately end up on disk if they invoke this method at close to the same time.
|
Create the directory the
See Also:
|
Construct a path referring to a sibling of this path. The resulting path will be unpredictable, so that other subprocesses should neither accidentally attempt to refer to the same path before it is created, nor they should other processes be able to guess its name in advance.
|
Copies self to destination. If self doesn't exist, an OSError is raised. If self is a directory, this method copies its children (but not itself) recursively to destination - if destination does not exist as a directory, this method creates it. If destination is a file, an IOError will be raised. If self is a file, this method copies it to destination. If destination is a file, this method overwrites it. If destination is a directory, an IOError will be raised. If self is a link (and followLinks is False), self will be copied over as a new symlink with the same target as returned by os.readlink. That means that if it is absolute, both the old and new symlink will link to the same thing. If it's relative, then perhaps not (and it's also possible that this relative link will be broken). File/directory permissions and ownership will NOT be copied over. If followLinks is True, symlinks are followed so that they're treated as their targets. In other words, if self is a link, the link's target will be copied. If destination is a link, self will be copied to the destination's target (the actual destination will be destination's target). Symlinks under self (if self is a directory) will be followed and its target's children be copied recursively. If followLinks is False, symlinks will be copied over as symlinks.
|
Move self to destination - basically renaming self to whatever destination is named. If destination is an already-existing directory, moves all children to destination if destination is empty. If destination is a non-empty directory, or destination is a file, an OSError will be raised. If moving between filesystems, self needs to be copied, and everything that applies to copyTo applies to moveTo.
|
Special descriptor for class __provides__ The descriptor caches the implementedBy info, so that we can get declarations for objects without instance-specific interfaces a bit quicker.
|
Class Variable Details |
__implemented__
|
Instance Variable Details |
statinfoThe currently cached status information about the file on the filesystem that thisFilePath points to. This attribute
is None if the file is in an indeterminate state (either
this FilePath has not yet had cause to call
stat() yet or FilePath.changed
indicated that new information is required), 0 if stat() was
called and returned an error (i.e. the path did not exist when
stat() was called), or a stat_result object
that describes the last known status of the underlying file (or
directory, as the case may be). Trust me when I tell you that you do not
want to use this attribute. Instead, use the methods on FilePath which give you information about it, like
getsize() , isdir() ,
getModificationTime() , and so on.
|
Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Wed Nov 21 16:22:49 2012 | http://epydoc.sourceforge.net |