PEP262 - database of installed packages
Thomas Heller
theller at python.net
Mon Mar 25 13:33:19 EST 2002
"Duncan Booth" <duncan at NOSPAMrcp.co.uk> wrote in message news:Xns91DCA870CFCCDduncanrcpcouk at 127.0.0.1...
> "Thomas Heller" <theller at python.net> wrote in news:a7nhv1$mqa0r$1 at ID-
> 59885.news.dfncis.de:
>
> > All true. On the other hand, Python has no possibility to display
> > or change the owner and access control lists (except if you do some
> > hardcore win32 programming).
>
> It is messy, but not hardcore:
>
> Python to display the owner of a file:
> os.system("dir /q " + filename)
> Likewise, to display or change the access control list
> os.system("cacls "+arguments)
> I don't know of an equivalent to change the owner of a file.
I doubt we want to have code like this in the PEP 262 implementation.
Here's what distutils does when copying a file (in file_util.py):
def copy_file(src, dst,
preserve_mode=1,
preserve_times=1,
...):
""" [...]
If 'preserve_mode'
is true (the default), the file's mode (type and permission bits, or
whatever is analogous on the current platform) is copied. If
'preserve_times' is true (the default), the last-modified and
last-access times are copied as well. [...]
"""
....
st = os.stat(src)
# According to David Ascher <da at ski.org>, utime() should be done
# before chmod() (at least under NT).
if preserve_times:
os.utime(dst, (st[ST_ATIME], st[ST_MTIME]))
if preserve_mode:
os.chmod(dst, S_IMODE(st[ST_MODE]))
So, for PEP 262, wouldn't it be sufficient to use "<unknown>" as user
(since we don't care), and the value of S_IMODE(st[ST_MODE]) as permission?
Thomas
More information about the Python-list
mailing list