Ich hab Rafaels Vearinate mal umgestrickt:
Code: Alles auswählen
def trans_chmod(mod):
trans_data = {
"0": "---",
"1": "--x",
"2": "-w-",
"3": "-wx",
"4": "r--",
"5": "r-x",
"6": "rw-",
"7": "rwx",
}
mod_string = "%04d" % mod
mod_string = mod_string[-3:]
return ''.join(trans_data[num] for num in mod_string)
Das Problem ist aber ein ganz anderes: os.stat()[stat.ST_MODE] liefert ein viel umfasserendes octal Schema zurück, als die einfache 3er Geschichte, die der Sourceocode oben abdeckt...
stat liefert z.B. solche Werte: 33188, 16877
Keine Ahnung wie man die behandeln sollte...
In dem zusammenhang hab ich das gefunden:
http://svn.pythonpaste.org/Paste/Script ... ckperms.py
Macht aber genau das falsche... Es konvertiert von Symbolisch in octalzahl...