Mercurial > hgrepos > Python > apps > py-cutils
diff cutils/util/walk.py @ 273:c02a57df2a29
treesum: - WalkDirEntry tests with a FIFO special file - WalkDirEntry.is_reg
Also all to be handled special files in the notes document.
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Wed, 19 Feb 2025 09:12:30 +0100 |
| parents | 0add8276e6b8 |
| children | 224725fd9f2f |
line wrap: on
line diff
--- a/cutils/util/walk.py Tue Feb 18 19:30:40 2025 +0100 +++ b/cutils/util/walk.py Wed Feb 19 09:12:30 2025 +0100 @@ -21,6 +21,7 @@ from scandir import scandir except ImportError: scandir = None +import stat import sys from . import PY2 @@ -53,8 +54,8 @@ """ __slots__ = ("_name", "_path", # encoded as given in the ctor - "_is_symlink", "_is_dir", "_stat_result", "_stat_errno", - "_stat_errstr", + "_is_symlink", "_is_reg", "_is_dir", "_stat_result", + "_stat_errno", "_stat_errstr", "_alt_fsname", "_alt_u8name") def __init__(self, name, path): @@ -62,7 +63,7 @@ """The name exactly as given in the ctor""" self._path = _unix_path(path) """The path as given in the ctor -- but normalized to have slashes""" - self._is_symlink = self._is_dir = self._stat_result = \ + self._is_symlink = self._is_reg = self._is_dir = self._stat_result = \ self._stat_errno = self._stat_errstr = None self._alt_fsname = self._alt_u8name = _notset @@ -227,6 +228,10 @@ return self._is_symlink @property + def is_reg(self): + return self._is_reg + + @property def is_dir(self): return self._is_dir @@ -278,6 +283,9 @@ w._stat_result = None w._stat_errno = e.errno w._stat_errstr = e.strerror + w._is_reg = False + else: + w._is_reg = stat.S_ISREG(w._stat_result.st_mode) return w @classmethod @@ -307,6 +315,9 @@ w._stat_result = None w._stat_errno = e.errno w._stat_errstr = e.strerror + w._is_reg = False + else: + w._is_reg = stat.S_ISREG(w._stat_result.st_mode) return w @classmethod
