-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDirEntryPath.py
More file actions
44 lines (36 loc) · 1.23 KB
/
DirEntryPath.py
File metadata and controls
44 lines (36 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import os
from pathlib import Path
class DirEntryPath(Path):
entry: os.DirEntry
def __init__(self, *args):
entry = args[0]
if isinstance(entry, os.DirEntry):
super().__init__(entry.path)
self.entry = entry
else:
super().__init__(*args)
def is_symlink(self):
if self.entry:
return self.entry.is_symlink()
else:
return super().is_symlink()
def is_dir(self, follow_symlinks=True):
if self.entry:
return self.entry.is_dir(follow_symlinks=follow_symlinks)
else:
return super().is_dir(follow_symlinks=follow_symlinks)
def is_file(self, follow_symlinks=True):
if self.entry:
return self.entry.is_file(follow_symlinks=follow_symlinks)
else:
return super().is_file(follow_symlinks=follow_symlinks)
def is_junction(self):
if self.entry:
return self.entry.is_junction()
else:
return super().is_junction()
def stat(self, *, follow_symlinks=True):
if self.entry:
return self.entry.stat(follow_symlinks=follow_symlinks)
else:
return super().stat(follow_symlinks=follow_symlinks)