lib.FileContext: Add file methods
Add the following methods, meant to do the obvious: unlink(self, path: str) -> None erase(self, path: str) -> None rename(self, src: str, dst: str) -> None mktemp(self, tmpl: str, directory: bool=False) -> None chown(self, path: str, owner: str|None=None, group: str|None=None) -> None chmod(self, path: str, mode: int) -> None stat(self, path: str, follow_symlinks: bool=True) -> StatResult file_exists(self, path: str) -> bool is_dir(self, path: str) -> bool All methods are async and call their protected counterpart, which is designed to be overridden. If possible, default implementations do something meaningful, if not, they just raise plain NotImplementedError. Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
parent
bc3ed1737f
commit
3cf5b2264e
5 changed files with 295 additions and 10 deletions
|
|
@ -44,9 +44,10 @@ class StatResult(NamedTuple):
|
|||
import pwd, grp
|
||||
return StatResult(
|
||||
rhs.st_mode,
|
||||
pwd.getpwuid(rhs.pw_uid).pw_name,
|
||||
grp.getgrgid(gid).gr_name,
|
||||
pwd.getpwuid(rhs.st_uid).pw_name,
|
||||
grp.getgrgid(rhs.st_gid).gr_name,
|
||||
rhs.st_size,
|
||||
rhs.st_atime,
|
||||
rhs.st_mtime,
|
||||
rhs.st_ctime,
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in a new issue