diff options
author | Lars Wirzenius <liw@liw.fi> | 2010-01-01 03:24:40 +0200 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2010-01-01 03:24:40 +0200 |
commit | 6fa9eaafd9faee987a555e8e9c338a82948896ac (patch) | |
tree | c96de42f897627245bcaaf102eb1e5223fd2b8e8 /summainlib.py | |
parent | eb85c7df4fcbeff0c28aeaa9329731dda9aace12 (diff) | |
download | summain-6fa9eaafd9faee987a555e8e9c338a82948896ac.tar.gz |
Implement formatting of symlink targets. With unit test.
Diffstat (limited to 'summainlib.py')
-rw-r--r-- | summainlib.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/summainlib.py b/summainlib.py index ad6fee0..1d0dfb4 100644 --- a/summainlib.py +++ b/summainlib.py @@ -35,10 +35,12 @@ class FilesystemObject(object): ''' def __init__(self, filename, stat_result=None, sha1=None, - open_file=None): + open_file=None, readlink=None): stat_result = stat_result or os.lstat(filename) sha1 = sha1 or hashlib.sha1() self.open_file = open_file or self.open_file + readlink = readlink or os.readlink + self.values = dict() self['Name'] = filename self['Mtime'] = self.format_time(stat_result.st_mtime) @@ -53,6 +55,8 @@ class FilesystemObject(object): self['Group'] = self.lookup_group(stat_result.st_gid) if stat.S_ISREG(stat_result.st_mode): self['Sha-1'] = self.compute_sha1(filename, sha1) + if stat.S_ISLNK(stat_result.st_mode): + self['Target'] = readlink(filename) def format_time(self, timestamp): return time.strftime('%Y-%m-%d %H:%M:%S +0000', |