doc/get_path_uuid
This commit is contained in:
parent
094d66bc33
commit
2327d5388d
1 changed files with 30 additions and 13 deletions
|
@ -33,27 +33,44 @@ def empty_file(path: Path) -> None:
|
||||||
write(path, "")
|
write(path, "")
|
||||||
|
|
||||||
|
|
||||||
def get_mount_uuid(path: str) -> str:
|
def get_mount_uuid(path: Path) -> str:
|
||||||
"""Return the filesystem UUID of a mountpoint path."""
|
"""Return the filesystem UUID of a mountpoint path.
|
||||||
|
|
||||||
|
:param path: mountpoint path
|
||||||
|
:type path: Path
|
||||||
|
:rtype: str
|
||||||
|
"""
|
||||||
return ps.run_line(
|
return ps.run_line(
|
||||||
("findmnt",),
|
"findmnt",
|
||||||
("--noheadings",),
|
"--noheadings",
|
||||||
("--output", "UUID"),
|
("--output", "UUID"),
|
||||||
(path,),
|
str(path),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def get_path_mount(path: str) -> str:
|
def get_path_mount(path: Path) -> Path:
|
||||||
"""Return the mountpoint path of an arbitrary path."""
|
"""Return the mountpoint path of an arbitrary path.
|
||||||
return ps.run_line(
|
|
||||||
|
:param path: arbitrary path
|
||||||
|
:type path: Path
|
||||||
|
:rtype: Path
|
||||||
|
"""
|
||||||
|
return Path(
|
||||||
|
ps.run_line(
|
||||||
"stat",
|
"stat",
|
||||||
("--format", "%m"),
|
("--format", "%m"),
|
||||||
path,
|
str(path),
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def get_path_uuid(path: str) -> str:
|
def get_path_uuid(path: Path) -> str:
|
||||||
"""Return the filesystem UUID of an arbitrary path."""
|
"""Return the filesystem UUID of an arbitrary path.
|
||||||
|
|
||||||
|
:param path: arbitrary path
|
||||||
|
:type path: Path
|
||||||
|
:rtype: str
|
||||||
|
"""
|
||||||
return get_mount_uuid(get_path_mount(path))
|
return get_mount_uuid(get_path_mount(path))
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue