MCPcopy Index your code
hub / github.com/python/cpython / filemode

Function filemode

Lib/stat.py:164–183  ·  view source on GitHub ↗

Convert a file's mode to a string of the form '-rwxrwxrwx'.

(mode)

Source from the content-addressed store, hash-verified

162)
163
164def filemode(mode):
165 """Convert a file's mode to a string of the form '-rwxrwxrwx'."""
166 perm = []
167 for index, table in enumerate(_filemode_table):
168 for bit, char in table:
169 if index == 0:
170 if S_IFMT(mode) == bit:
171 perm.append(char)
172 break
173 else:
174 if mode & bit == bit:
175 perm.append(char)
176 break
177 else:
178 if index == 0:
179 # Unknown filetype
180 perm.append("?")
181 else:
182 perm.append("-")
183 return "".join(perm)
184
185
186# Windows FILE_ATTRIBUTE constants for interpreting os.stat()'s

Callers

nothing calls this directly

Calls 4

enumerateFunction · 0.85
S_IFMTFunction · 0.85
appendMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…