Last active
April 26, 2022 10:46
-
-
Save Xeckt/eecba0844722a7c69aa1db3326ec4ee9 to your computer and use it in GitHub Desktop.
Get Unix permission masks for file(s) in Python.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://docs.python.org/3/library/stat.html | |
import os as system | |
permission_index = { | |
0: 'st_mode', | |
1: 'st_ino', | |
2: 'st_dev', | |
3: 'st_nlink', | |
4: 'st_uid', | |
5: 'st_gid', | |
6: 'st_size', | |
7: 'st_atime', | |
8: 'st_mtime', | |
9: 'st_ctime' | |
} | |
def get_permission_bits(self, file): | |
file_ids = self.system.stat(file) | |
for index, ids in enumerate(file_ids): | |
bit_list = [index, ids, permission_index[index]] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment