From 63c2c03abd973adb2794e15a96a2b39a4790f65b Mon Sep 17 00:00:00 2001 From: Andrew Leech Date: Mon, 21 Aug 2023 12:13:56 +0930 Subject: [PATCH] stdlib/os: Provide namedtuple response for os.stat(). --- python-stdlib/os/os/__init__.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/python-stdlib/os/os/__init__.py b/python-stdlib/os/os/__init__.py index e4acabc8..4ebdb63c 100644 --- a/python-stdlib/os/os/__init__.py +++ b/python-stdlib/os/os/__init__.py @@ -1,5 +1,6 @@ # Include built-in os module. import sys + __path = sys.path try: sys.path.clear() @@ -12,3 +13,28 @@ try: from . import path except ImportError: pass + +from collections import namedtuple + +# https://docs.python.org/3/library/os.html#os.stat_result +stat_result = namedtuple( + "stat_result", + ( + "st_mode", + "st_ino", + "st_dev", + "st_nlink", + "st_uid", + "st_gid", + "st_size", + "st_atime", + "st_mtime", + "st_ctime", + ), +) + +__os_stat = stat + + +def stat(path): + return stat_result(*__os_stat(path))