Mercurial > cpython-lru_cache-weakref
annotate Lib/stat.py @ 58765:2ba7677bfa95 legacy-trunk
testCopysign was defined twice in test_math; combine the definitions
| author | Mark Dickinson <dickinsm@gmail.com> |
|---|---|
| date | Sat, 06 Feb 2010 23:11:25 +0000 |
| parents | 06e641cb3a20 |
| children | abfe28e7e5cd |
| rev | line source |
|---|---|
|
11707
6f4146846337
The third and final doc-string sweep by Ka-Ping Yee.
Guido van Rossum <guido@python.org>
parents:
1810
diff
changeset
|
1 """Constants/functions for interpreting results of os.stat() and os.lstat(). |
|
6f4146846337
The third and final doc-string sweep by Ka-Ping Yee.
Guido van Rossum <guido@python.org>
parents:
1810
diff
changeset
|
2 |
|
6f4146846337
The third and final doc-string sweep by Ka-Ping Yee.
Guido van Rossum <guido@python.org>
parents:
1810
diff
changeset
|
3 Suggested usage: from stat import * |
|
6f4146846337
The third and final doc-string sweep by Ka-Ping Yee.
Guido van Rossum <guido@python.org>
parents:
1810
diff
changeset
|
4 """ |
|
6f4146846337
The third and final doc-string sweep by Ka-Ping Yee.
Guido van Rossum <guido@python.org>
parents:
1810
diff
changeset
|
5 |
|
45952
06e641cb3a20
#2383: remove obsolete XXX comment in stat.py.
Georg Brandl <georg@python.org>
parents:
40872
diff
changeset
|
6 # Indices for stat struct members in the tuple returned by os.stat() |
| 20 | 7 |
| 8 ST_MODE = 0 | |
| 9 ST_INO = 1 | |
| 10 ST_DEV = 2 | |
| 11 ST_NLINK = 3 | |
| 12 ST_UID = 4 | |
| 13 ST_GID = 5 | |
| 14 ST_SIZE = 6 | |
| 15 ST_ATIME = 7 | |
| 16 ST_MTIME = 8 | |
| 17 ST_CTIME = 9 | |
| 18 | |
|
775
45b3a78f256b
Use bitwise ops instead of %; added some warnings and comments
Guido van Rossum <guido@python.org>
parents:
559
diff
changeset
|
19 # Extract bits from the mode |
|
45b3a78f256b
Use bitwise ops instead of %; added some warnings and comments
Guido van Rossum <guido@python.org>
parents:
559
diff
changeset
|
20 |
|
56
a7e8fb7bb6a2
Added S_IMODE() to strip the file type (S_IFMT) from a mode.
Guido van Rossum <guido@python.org>
parents:
20
diff
changeset
|
21 def S_IMODE(mode): |
|
15872
3685ef2a55a4
Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents:
11707
diff
changeset
|
22 return mode & 07777 |
|
775
45b3a78f256b
Use bitwise ops instead of %; added some warnings and comments
Guido van Rossum <guido@python.org>
parents:
559
diff
changeset
|
23 |
| 20 | 24 def S_IFMT(mode): |
|
15872
3685ef2a55a4
Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents:
11707
diff
changeset
|
25 return mode & 0170000 |
|
775
45b3a78f256b
Use bitwise ops instead of %; added some warnings and comments
Guido van Rossum <guido@python.org>
parents:
559
diff
changeset
|
26 |
|
45b3a78f256b
Use bitwise ops instead of %; added some warnings and comments
Guido van Rossum <guido@python.org>
parents:
559
diff
changeset
|
27 # Constants used as S_IFMT() for various file types |
|
45b3a78f256b
Use bitwise ops instead of %; added some warnings and comments
Guido van Rossum <guido@python.org>
parents:
559
diff
changeset
|
28 # (not all are implemented on all systems) |
| 20 | 29 |
| 30 S_IFDIR = 0040000 | |
| 31 S_IFCHR = 0020000 | |
| 32 S_IFBLK = 0060000 | |
| 33 S_IFREG = 0100000 | |
| 34 S_IFIFO = 0010000 | |
| 35 S_IFLNK = 0120000 | |
| 36 S_IFSOCK = 0140000 | |
| 37 | |
|
775
45b3a78f256b
Use bitwise ops instead of %; added some warnings and comments
Guido van Rossum <guido@python.org>
parents:
559
diff
changeset
|
38 # Functions to test for each file type |
|
45b3a78f256b
Use bitwise ops instead of %; added some warnings and comments
Guido van Rossum <guido@python.org>
parents:
559
diff
changeset
|
39 |
| 20 | 40 def S_ISDIR(mode): |
|
15872
3685ef2a55a4
Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents:
11707
diff
changeset
|
41 return S_IFMT(mode) == S_IFDIR |
| 20 | 42 |
| 43 def S_ISCHR(mode): | |
|
15872
3685ef2a55a4
Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents:
11707
diff
changeset
|
44 return S_IFMT(mode) == S_IFCHR |
| 20 | 45 |
| 46 def S_ISBLK(mode): | |
|
15872
3685ef2a55a4
Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents:
11707
diff
changeset
|
47 return S_IFMT(mode) == S_IFBLK |
| 20 | 48 |
| 49 def S_ISREG(mode): | |
|
15872
3685ef2a55a4
Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents:
11707
diff
changeset
|
50 return S_IFMT(mode) == S_IFREG |
| 20 | 51 |
| 52 def S_ISFIFO(mode): | |
|
15872
3685ef2a55a4
Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents:
11707
diff
changeset
|
53 return S_IFMT(mode) == S_IFIFO |
| 20 | 54 |
| 55 def S_ISLNK(mode): | |
|
15872
3685ef2a55a4
Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents:
11707
diff
changeset
|
56 return S_IFMT(mode) == S_IFLNK |
| 20 | 57 |
| 58 def S_ISSOCK(mode): | |
|
15872
3685ef2a55a4
Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents:
11707
diff
changeset
|
59 return S_IFMT(mode) == S_IFSOCK |
|
852
1ac5c6727e8c
Add names for perm bits (S_IREAD etc).
Guido van Rossum <guido@python.org>
parents:
775
diff
changeset
|
60 |
|
1ac5c6727e8c
Add names for perm bits (S_IREAD etc).
Guido van Rossum <guido@python.org>
parents:
775
diff
changeset
|
61 # Names for permission bits |
|
1ac5c6727e8c
Add names for perm bits (S_IREAD etc).
Guido van Rossum <guido@python.org>
parents:
775
diff
changeset
|
62 |
|
1ac5c6727e8c
Add names for perm bits (S_IREAD etc).
Guido van Rossum <guido@python.org>
parents:
775
diff
changeset
|
63 S_ISUID = 04000 |
|
1ac5c6727e8c
Add names for perm bits (S_IREAD etc).
Guido van Rossum <guido@python.org>
parents:
775
diff
changeset
|
64 S_ISGID = 02000 |
|
1ac5c6727e8c
Add names for perm bits (S_IREAD etc).
Guido van Rossum <guido@python.org>
parents:
775
diff
changeset
|
65 S_ENFMT = S_ISGID |
|
1ac5c6727e8c
Add names for perm bits (S_IREAD etc).
Guido van Rossum <guido@python.org>
parents:
775
diff
changeset
|
66 S_ISVTX = 01000 |
|
1ac5c6727e8c
Add names for perm bits (S_IREAD etc).
Guido van Rossum <guido@python.org>
parents:
775
diff
changeset
|
67 S_IREAD = 00400 |
|
1ac5c6727e8c
Add names for perm bits (S_IREAD etc).
Guido van Rossum <guido@python.org>
parents:
775
diff
changeset
|
68 S_IWRITE = 00200 |
|
1ac5c6727e8c
Add names for perm bits (S_IREAD etc).
Guido van Rossum <guido@python.org>
parents:
775
diff
changeset
|
69 S_IEXEC = 00100 |
|
1ac5c6727e8c
Add names for perm bits (S_IREAD etc).
Guido van Rossum <guido@python.org>
parents:
775
diff
changeset
|
70 S_IRWXU = 00700 |
|
1ac5c6727e8c
Add names for perm bits (S_IREAD etc).
Guido van Rossum <guido@python.org>
parents:
775
diff
changeset
|
71 S_IRUSR = 00400 |
|
1ac5c6727e8c
Add names for perm bits (S_IREAD etc).
Guido van Rossum <guido@python.org>
parents:
775
diff
changeset
|
72 S_IWUSR = 00200 |
|
1ac5c6727e8c
Add names for perm bits (S_IREAD etc).
Guido van Rossum <guido@python.org>
parents:
775
diff
changeset
|
73 S_IXUSR = 00100 |
|
1ac5c6727e8c
Add names for perm bits (S_IREAD etc).
Guido van Rossum <guido@python.org>
parents:
775
diff
changeset
|
74 S_IRWXG = 00070 |
|
1ac5c6727e8c
Add names for perm bits (S_IREAD etc).
Guido van Rossum <guido@python.org>
parents:
775
diff
changeset
|
75 S_IRGRP = 00040 |
|
1ac5c6727e8c
Add names for perm bits (S_IREAD etc).
Guido van Rossum <guido@python.org>
parents:
775
diff
changeset
|
76 S_IWGRP = 00020 |
|
1ac5c6727e8c
Add names for perm bits (S_IREAD etc).
Guido van Rossum <guido@python.org>
parents:
775
diff
changeset
|
77 S_IXGRP = 00010 |
|
1ac5c6727e8c
Add names for perm bits (S_IREAD etc).
Guido van Rossum <guido@python.org>
parents:
775
diff
changeset
|
78 S_IRWXO = 00007 |
|
1ac5c6727e8c
Add names for perm bits (S_IREAD etc).
Guido van Rossum <guido@python.org>
parents:
775
diff
changeset
|
79 S_IROTH = 00004 |
|
1ac5c6727e8c
Add names for perm bits (S_IREAD etc).
Guido van Rossum <guido@python.org>
parents:
775
diff
changeset
|
80 S_IWOTH = 00002 |
|
1ac5c6727e8c
Add names for perm bits (S_IREAD etc).
Guido van Rossum <guido@python.org>
parents:
775
diff
changeset
|
81 S_IXOTH = 00001 |
|
40872
53fd144a3f1a
Patch #1490190: posixmodule now includes os.chflags() and os.lchflags()
Martin v. Löwis <martin@v.loewis.de>
parents:
16657
diff
changeset
|
82 |
|
53fd144a3f1a
Patch #1490190: posixmodule now includes os.chflags() and os.lchflags()
Martin v. Löwis <martin@v.loewis.de>
parents:
16657
diff
changeset
|
83 # Names for file flags |
|
53fd144a3f1a
Patch #1490190: posixmodule now includes os.chflags() and os.lchflags()
Martin v. Löwis <martin@v.loewis.de>
parents:
16657
diff
changeset
|
84 |
|
53fd144a3f1a
Patch #1490190: posixmodule now includes os.chflags() and os.lchflags()
Martin v. Löwis <martin@v.loewis.de>
parents:
16657
diff
changeset
|
85 UF_NODUMP = 0x00000001 |
|
53fd144a3f1a
Patch #1490190: posixmodule now includes os.chflags() and os.lchflags()
Martin v. Löwis <martin@v.loewis.de>
parents:
16657
diff
changeset
|
86 UF_IMMUTABLE = 0x00000002 |
|
53fd144a3f1a
Patch #1490190: posixmodule now includes os.chflags() and os.lchflags()
Martin v. Löwis <martin@v.loewis.de>
parents:
16657
diff
changeset
|
87 UF_APPEND = 0x00000004 |
|
53fd144a3f1a
Patch #1490190: posixmodule now includes os.chflags() and os.lchflags()
Martin v. Löwis <martin@v.loewis.de>
parents:
16657
diff
changeset
|
88 UF_OPAQUE = 0x00000008 |
|
53fd144a3f1a
Patch #1490190: posixmodule now includes os.chflags() and os.lchflags()
Martin v. Löwis <martin@v.loewis.de>
parents:
16657
diff
changeset
|
89 UF_NOUNLINK = 0x00000010 |
|
53fd144a3f1a
Patch #1490190: posixmodule now includes os.chflags() and os.lchflags()
Martin v. Löwis <martin@v.loewis.de>
parents:
16657
diff
changeset
|
90 SF_ARCHIVED = 0x00010000 |
|
53fd144a3f1a
Patch #1490190: posixmodule now includes os.chflags() and os.lchflags()
Martin v. Löwis <martin@v.loewis.de>
parents:
16657
diff
changeset
|
91 SF_IMMUTABLE = 0x00020000 |
|
53fd144a3f1a
Patch #1490190: posixmodule now includes os.chflags() and os.lchflags()
Martin v. Löwis <martin@v.loewis.de>
parents:
16657
diff
changeset
|
92 SF_APPEND = 0x00040000 |
|
53fd144a3f1a
Patch #1490190: posixmodule now includes os.chflags() and os.lchflags()
Martin v. Löwis <martin@v.loewis.de>
parents:
16657
diff
changeset
|
93 SF_NOUNLINK = 0x00100000 |
|
53fd144a3f1a
Patch #1490190: posixmodule now includes os.chflags() and os.lchflags()
Martin v. Löwis <martin@v.loewis.de>
parents:
16657
diff
changeset
|
94 SF_SNAPSHOT = 0x00200000 |
