summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorhut <hut@lepus.uberspace.de>2014-12-03 17:06:39 +0100
committerhut <hut@lepus.uberspace.de>2014-12-03 17:08:54 +0100
commit58c2185f5fc5a5af1a7eccb727db61f2050cc66f (patch)
tree2b09057e83e3bcb88eb33b5a28a811f6d97420f2
parent3e0aa7a0ae37768dbe19f07ae086d3ded0064d19 (diff)
downloadranger-58c2185f5fc5a5af1a7eccb727db61f2050cc66f.tar.gz
added fsobject.user and fsobject.group lazy_properties
-rw-r--r--ranger/container/fsobject.py15
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("