242 def __init__(self, func): |
242 def __init__(self, func): |
243 self.func = func |
243 self.func = func |
244 self.name = func.__name__ |
244 self.name = func.__name__ |
245 def __get__(self, obj, type=None): |
245 def __get__(self, obj, type=None): |
246 result = self.func(obj) |
246 result = self.func(obj) |
247 setattr(obj, self.name, result) |
247 self.cachevalue(obj, result) |
248 return result |
248 return result |
|
249 |
|
250 def cachevalue(self, obj, value): |
|
251 setattr(obj, self.name, value) |
249 |
252 |
250 def pipefilter(s, cmd): |
253 def pipefilter(s, cmd): |
251 '''filter string S through command CMD, returning its output''' |
254 '''filter string S through command CMD, returning its output''' |
252 p = subprocess.Popen(cmd, shell=True, close_fds=closefds, |
255 p = subprocess.Popen(cmd, shell=True, close_fds=closefds, |
253 stdin=subprocess.PIPE, stdout=subprocess.PIPE) |
256 stdin=subprocess.PIPE, stdout=subprocess.PIPE) |