mirror of
ssh://git.janware.com/janware/proj/jw-pkg
synced 2026-04-24 17:23:36 +02:00
lib.base.StatResult: Add type
Add the basic type StatResult. It is something akin to os.stat_result, but with user and group string members instead of st_uid and st_gid. The latter can't be expected to be stable across remote contexts. Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
parent
154db1ebc4
commit
bc3ed1737f
1 changed files with 22 additions and 0 deletions
|
|
@ -28,3 +28,25 @@ class Result(NamedTuple):
|
||||||
self.stderr.decode(encoding, errors=errors) if self.stderr is not None else None,
|
self.stderr.decode(encoding, errors=errors) if self.stderr is not None else None,
|
||||||
self.status
|
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,
|
||||||
|
)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue