diff --git a/src/python/jw/pkg/lib/base.py b/src/python/jw/pkg/lib/base.py index 793bd09e..81c232e5 100644 --- a/src/python/jw/pkg/lib/base.py +++ b/src/python/jw/pkg/lib/base.py @@ -28,3 +28,25 @@ class Result(NamedTuple): self.stderr.decode(encoding, errors=errors) if self.stderr is not None else None, self.status ) + +class StatResult(NamedTuple): + + mode: int + owner: str + group: str + size: int + atime: int + mtime: int + ctime: int + + @classmethod + def from_os(cls, rhs: os.stat_result) -> StatResult: + import pwd, grp + return StatResult( + rhs.st_mode, + pwd.getpwuid(rhs.pw_uid).pw_name, + grp.getgrgid(gid).gr_name, + rhs.st_size, + rhs.st_mtime, + rhs.st_ctime, + )