New submission from Pavol Babinčák <scroo...@gmail.com>: I'm using Windows and lets' say I have this directory structure listed with cmd:
> dir /A ... 16.05.20 11:15 <DIR> directory 16.05.20 10:47 0 hidden 16.05.20 11:25 <SYMLINK> link [regular] 16.05.20 10:47 0 readonly 16.05.20 11:15 0 regular 16.05.20 10:48 0 system ... or PowerShell: PS > dir -Force Mode LastWriteTime Length Name ---- ------------- ------ ---- d----- 16.5.20 11:15 directory -a-h-- 16.5.20 10:47 0 hidden -a---l 16.5.20 11:25 0 link -ar--- 16.5.20 10:47 0 readonly -a---- 16.5.20 11:15 0 regular -a--s- 16.5.20 10:48 0 system or attrib: > attrib A H hidden A link A R readonly A regular A S system I'd like to print file attributes in a text form. If I use stat.filemode(): >>> import os, stat >>> print("\n".join(["{} {}".format(stat.filemode(os.stat(n).st_mode), n) for n >>> in os.listdir('.')])) drwxrwxrwx directory -rw-rw-rw- hidden -rw-rw-rw- link -r--r--r-- readonly -rw-rw-rw- regular -rw-rw-rw- system >>> not surprisingly I miss all windows attributes. On the top of that I get only values of stat.S_IWRITE and stat.S_IREAD as documented in os.chmod(). I'd like to have a new function, let's say fileattributes() which would behave like this: >>> print("\n".join(["{} >>> {}".format(stat.fileattributes(os.stat(n).st_file_attributes), n) for n in >>> os.listdir('.')])) d----- directory -a-h-- hidden -a---l link -ar--- readonly -a---- regular -a--s- system >>> In this example I have used same format of attributes as in PowerShell because it is most similar to filemode(). I guess link cannot be currently identified with contants in stat module. ---------- components: Library (Lib) messages: 369041 nosy: scrool priority: normal severity: normal status: open title: Text representation of Windows' file attributes similar to stat.filemode() type: enhancement versions: Python 3.9 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue40644> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com