Mercurial > hgrepos > Python > apps > py-cutils
diff cutils/util/walk.py @ 198:c1e875ba4bdc
Put the effective filesystem encoding into the treesum digest file using FSENCODING = <encoding>
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Thu, 16 Jan 2025 23:18:04 +0100 |
| parents | 0f4febf646f5 |
| children | b2aba84ca426 |
line wrap: on
line diff
--- a/cutils/util/walk.py Thu Jan 16 20:40:24 2025 +0100 +++ b/cutils/util/walk.py Thu Jan 16 23:18:04 2025 +0100 @@ -10,7 +10,7 @@ from __future__ import print_function, absolute_import -__all__ = ["ScanDir"] +__all__ = ["ScanDir", "getfsencoding"] import os @@ -21,10 +21,14 @@ from scandir import scandir except ImportError: scandir = None +import sys from . import PY2 +_FSENCODING = sys.getfilesystemencoding() + + class WalkDirEntry(object): """A :class:`os.DirEntry` alike to be used in :func:`walk` and for @@ -41,6 +45,7 @@ assert isinstance(name, bytes) self._fsname = name else: + self._name = name self._fsname = os.fsencode(name) self._path = None self._fspath = None @@ -209,3 +214,8 @@ def __exit__(self, *args, **kwds): pass + + +def getfsencoding(): + """Return the stored _FSENCODING of this module""" + return _FSENCODING
