Skip to content

Commit f4cfc3c

Browse files
pi-anldpgeorge
authored andcommitted
os: Provide namedtuple response for os.stat().
Having the option to wrap / return os.stat() with the cpython standard format can greatly aid in porting third party libraries.
1 parent 4dfa813 commit f4cfc3c

2 files changed

Lines changed: 26 additions & 1 deletion

File tree

python-stdlib/os/manifest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
metadata(version="0.6.0")
1+
metadata(version="0.7.0")
22

33
# Originally written by Paul Sokolovsky.
44

python-stdlib/os/os/__init__.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,28 @@
66
from . import path
77
except ImportError:
88
pass
9+
10+
from collections import namedtuple
11+
12+
# https://docs.python.org/3/library/os.html#os.stat_result
13+
stat_result = namedtuple(
14+
"stat_result",
15+
(
16+
"st_mode",
17+
"st_ino",
18+
"st_dev",
19+
"st_nlink",
20+
"st_uid",
21+
"st_gid",
22+
"st_size",
23+
"st_atime",
24+
"st_mtime",
25+
"st_ctime",
26+
),
27+
)
28+
29+
__os_stat = stat
30+
31+
32+
def stat(path):
33+
return stat_result(*__os_stat(path))

0 commit comments

Comments
 (0)