MCPcopy
hub / github.com/pytest-dev/pytest / Stat

Class Stat

src/_pytest/_py/path.py:203–246  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

201
202
203class Stat:
204 if TYPE_CHECKING:
205
206 @property
207 def size(self) -> int: ...
208
209 @property
210 def mtime(self) -> float: ...
211
212 def __getattr__(self, name: str) -> Any:
213 return getattr(self._osstatresult, "st_" + name)
214
215 def __init__(self, path, osstatresult):
216 self.path = path
217 self._osstatresult = osstatresult
218
219 @property
220 def owner(self):
221 if iswin32:
222 raise NotImplementedError("XXX win32")
223 import pwd
224
225 entry = error.checked_call(pwd.getpwuid, self.uid) # type:ignore[attr-defined,unused-ignore]
226 return entry[0]
227
228 @property
229 def group(self):
230 """Return group name of file."""
231 if iswin32:
232 raise NotImplementedError("XXX win32")
233 import grp
234
235 entry = error.checked_call(grp.getgrgid, self.gid) # type:ignore[attr-defined,unused-ignore]
236 return entry[0]
237
238 def isdir(self):
239 return S_ISDIR(self._osstatresult.st_mode)
240
241 def isfile(self):
242 return S_ISREG(self._osstatresult.st_mode)
243
244 def islink(self):
245 self.path.lstat()
246 return S_ISLNK(self._osstatresult.st_mode)
247
248
249def getuserid(user):

Callers 2

statMethod · 0.85
lstatMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected