diff options
author | hut <hut@lavabit.com> | 2009-12-22 15:55:11 +0100 |
---|---|---|
committer | hut <hut@lavabit.com> | 2009-12-22 15:55:11 +0100 |
commit | 4fb1670e4d87aecf2eee8a1ba4903f9d8cdae914 (patch) | |
tree | 752d2f331780bad1ee204605c031c19f5b07f644 /ranger | |
parent | fa704babe536ebd6409a939cfb684d5ac281de8a (diff) | |
download | ranger-4fb1670e4d87aecf2eee8a1ba4903f9d8cdae914.tar.gz |
slightly improved get_permission_string() algorithm
Diffstat (limited to 'ranger')
-rw-r--r-- | ranger/fsobject/fsobject.py | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/ranger/fsobject/fsobject.py b/ranger/fsobject/fsobject.py index 854b05ac..10a97fd5 100644 --- a/ranger/fsobject/fsobject.py +++ b/ranger/fsobject/fsobject.py @@ -154,23 +154,24 @@ class FileSystemObject(MimeTypeAware, FileManagerAware): return '----------' import stat - perms = '-' mode = self.stat.st_mode if stat.S_ISDIR(mode): - perms = 'd' + perms = ['d'] elif stat.S_ISLNK(mode): - perms = 'l' + perms = ['l'] + else: + perms = ['-'] for who in "USR", "GRP", "OTH": - for what in "R", "W", "X": - if mode & getattr(stat,"S_I"+what+who): - perms=perms+what.lower() + for what in "rwx": + if mode & getattr(stat, "S_I" + what.upper() + who): + perms.append( what.lower() ) else: - perms=perms+"-" + perms.append( '-' ) - self.permissions = perms - return perms + self.permissions = ''.join(perms) + return self.permissions def load_once(self): """calls load() if it has not been called at least once yet""" |