diff options
author | hut <hut@lepus.uberspace.de> | 2014-12-03 17:06:39 +0100 |
---|---|---|
committer | hut <hut@lepus.uberspace.de> | 2014-12-03 17:08:54 +0100 |
commit | 58c2185f5fc5a5af1a7eccb727db61f2050cc66f (patch) | |
tree | 2b09057e83e3bcb88eb33b5a28a811f6d97420f2 /ranger | |
parent | 3e0aa7a0ae37768dbe19f07ae086d3ded0064d19 (diff) | |
download | ranger-58c2185f5fc5a5af1a7eccb727db61f2050cc66f.tar.gz |
added fsobject.user and fsobject.group lazy_properties
Diffstat (limited to 'ranger')
-rw-r--r-- | ranger/container/fsobject.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/ranger/container/fsobject.py b/ranger/container/fsobject.py index 1bdbcde7..59aea478 100644 --- a/ranger/container/fsobject.py +++ b/ranger/container/fsobject.py @@ -13,8 +13,10 @@ DOCUMENT_BASENAMES = ('bugs', 'bugs', 'changelog', 'copying', 'credits', BAD_INFO = '?' import re +from grp import getgrgid from os import lstat, stat, getcwd from os.path import abspath, basename, dirname, realpath, splitext, extsep, relpath +from pwd import getpwuid from ranger.core.shared import FileManagerAware, SettingsAware from ranger.ext.shell_escape import shell_escape from ranger.ext.spawn import spawn @@ -132,6 +134,19 @@ class FileSystemObject(FileManagerAware, SettingsAware): def safe_basename(self): return self.basename.translate(_safe_string_table) + @lazy_property + def user(self): + try: + return getpwuid(self.stat.st_uid)[0] + except: + return str(self.stat.st_uid) + + @lazy_property + def group(self): + try: + return getgrgid(self.stat.st_gid)[0] + except: + return str(self.stat.st_gid) for attr in ('video', 'audio', 'image', 'media', 'document', 'container'): exec("%s = lazy_property(" |