Skip to content

Commit aac74a8

Browse files
committed
stdlib/os: Provide namedtuple response for os.stat().
1 parent 82501d7 commit aac74a8

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

python-stdlib/os/os/__init__.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Include built-in os module.
22
import sys
3+
34
__path = sys.path
45
try:
56
sys.path.clear()
@@ -12,3 +13,28 @@
1213
from . import path
1314
except ImportError:
1415
pass
16+
17+
from collections import namedtuple
18+
19+
# https://docs.python.org/3/library/os.html#os.stat_result
20+
stat_result = namedtuple(
21+
"stat_result",
22+
(
23+
"st_mode",
24+
"st_ino",
25+
"st_dev",
26+
"st_nlink",
27+
"st_uid",
28+
"st_gid",
29+
"st_size",
30+
"st_atime",
31+
"st_mtime",
32+
"st_ctime",
33+
),
34+
)
35+
36+
__os_stat = stat
37+
38+
39+
def stat(path):
40+
return stat_result(*__os_stat(path))

0 commit comments

Comments
 (0)