feat: CMD-ENTER file info toegevoegd
This commit is contained in:
Binary file not shown.
@@ -1,11 +1,38 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import shutil
|
||||
import mimetypes
|
||||
import grp
|
||||
import pwd
|
||||
from datetime import datetime, timezone
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
class FilesystemAdapter:
|
||||
def stat_info(self, path: Path) -> dict:
|
||||
stat = path.stat()
|
||||
owner = None
|
||||
group = None
|
||||
try:
|
||||
owner = pwd.getpwuid(stat.st_uid).pw_name
|
||||
except (KeyError, ImportError, AttributeError):
|
||||
owner = None
|
||||
try:
|
||||
group = grp.getgrgid(stat.st_gid).gr_name
|
||||
except (KeyError, ImportError, AttributeError):
|
||||
group = None
|
||||
|
||||
content_type, _ = mimetypes.guess_type(path.name)
|
||||
return {
|
||||
"name": path.name,
|
||||
"size": int(stat.st_size) if path.is_file() else None,
|
||||
"modified": datetime.fromtimestamp(stat.st_mtime, tz=timezone.utc).isoformat().replace("+00:00", "Z"),
|
||||
"owner": owner,
|
||||
"group": group,
|
||||
"content_type": content_type,
|
||||
"extension": path.suffix.lower() or None,
|
||||
}
|
||||
|
||||
def list_directory(self, directory: Path, show_hidden: bool) -> tuple[list[dict], list[dict]]:
|
||||
directories: list[dict] = []
|
||||
files: list[dict] = []
|
||||
|
||||
Reference in New Issue
Block a user