summaryrefslogtreecommitdiff
path: root/summainlib.py
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2010-01-01 03:02:20 +0200
committerLars Wirzenius <liw@liw.fi>2010-01-01 03:02:20 +0200
commit37810eaf498b82c8fb54bcf22c0861ad2c370d69 (patch)
tree9c6446dcfddb4c109c2d3389aa176d2adc781058 /summainlib.py
parent769ff2d2dd5434cec535a8ff4be9a9ba3a81e4bf (diff)
downloadsummain-37810eaf498b82c8fb54bcf22c0861ad2c370d69.tar.gz
Implement formatting of st_gid.
Implement lookup of group name corresponding to st_gid. With unit tests.
Diffstat (limited to 'summainlib.py')
-rw-r--r--summainlib.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/summainlib.py b/summainlib.py
index ff0bf12..4d0a89c 100644
--- a/summainlib.py
+++ b/summainlib.py
@@ -14,6 +14,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
+import grp
import os
import pwd
import time
@@ -43,6 +44,8 @@ class FilesystemObject(object):
self['Size'] = '%d' % stat_result.st_size
self['Uid'] = '%d' % stat_result.st_uid
self['Username'] = self.lookup_username(stat_result.st_uid)
+ self['Gid'] = '%d' % stat_result.st_gid
+ self['Group'] = self.lookup_group(stat_result.st_gid)
def format_time(self, timestamp):
return time.strftime('%Y-%m-%d %H:%M:%S +0000',
@@ -51,6 +54,9 @@ class FilesystemObject(object):
def lookup_username(self, uid):
return pwd.getpwuid(uid).pw_name
+ def lookup_group(self, gid):
+ return grp.getgrgid(gid).gr_name
+
def hook_name(self, value):
return urllib.quote(value)