Next
/
Previous
/ Index
/ TCC Help System
/ Publications
/ Site map
/ NM Tech homepage
pathinfo.py: A Python file info object
|
|
The PathInfo object, defined in the
pathinfo.py source file,
represents status information for a file or directory.
It is basically just some sugarcoating around the standard
Python library functions from the os module.
Its built-in .__str__() method displays the file's
information on a line with this format,
drwxrwxrwx yyyy-mm-dd hh:mm:ss p
that is, the permissions (as in the Unix ls command),
the modification timestamp, and the pathname.
Exported methods in the PathInfo object are listed
below. Methods described as ``predicates'' return a nonzero
integer for true, zero for false.
- PathInfo(pathname): Returns a new object
representing the status of the pathname, if any. If there
is no such pathname, an exception is raised.
- .size(): Returns the file's size in bytes.
- .ownerCanRead(): Predicate for testing whether
the owner can read the path, that is, it returns true if and
only if the owner has read permission.
- .ownerCanWrite(): Predicate for testing whether
the owner has write permission.
- .ownerCanExec(): Predicate for testing owner's
execute permission.
- .groupCanRead(): Predicate for testing group read permission.
- .groupCanWrite(): Predicate for testing group write permission.
- .groupCanExec(): Predicate for testing group execute
permission.
- .worldCanRead(): Predicate for testing world read permission.
- .worldCanWrite(): Predicate for testing world write permission.
- .worldCanExec(): Predicate for testing world execute
permission.
- .isDir(): Predicate for testing whether a path is a
directory.
- .isFile(): Predicate for testing whether a path is an
ordinary file.
- .isLink(): Predicate for testing whether a path is a soft
link.
See also: Systems programming in Python
Previous: oldfiles: Where are my oldest files?
Site map
Index:
Keyword index
to help pages
Help:
New Mexico Tech Computer Center: Help System
TCC Publications
To report a problem: File a ticket
Send mail to the User consultant
on duty or call them at 575-835-5437
Home:
About New Mexico Tech
John Shipman, john@nmt.edu
Last updated: 2004/03/07 01:47:13 UT
URL: http://www.nmt.edu/tcc/help/lang/python/pathinfo.html
|
|