##// END OF EJS Templates
changelog: change the implementation of `_divertopener`...
marmoute -
r44985:897f0ce4 default
parent child Browse files
Show More
@@ -164,15 +164,18 b' class appender(object):'
164 return self.fp.__exit__(*args)
164 return self.fp.__exit__(*args)
165
165
166
166
167 def _divertopener(opener, target):
167 class _divertopener(object):
168 """build an opener that writes in 'target.a' instead of 'target'"""
168 def __init__(self, opener, target):
169 self._opener = opener
170 self._target = target
169
171
170 def _divert(name, mode=b'r', checkambig=False, **kwargs):
172 def __call__(self, name, mode=b'r', checkambig=False, **kwargs):
171 if name != target:
173 if name != self._target:
172 return opener(name, mode, **kwargs)
174 return self._opener(name, mode, **kwargs)
173 return opener(name + b".a", mode, **kwargs)
175 return self._opener(name + b".a", mode, **kwargs)
174
176
175 return _divert
177 def __getattr__(self, attr):
178 return getattr(self._opener, attr)
176
179
177
180
178 def _delayopener(opener, target, buf):
181 def _delayopener(opener, target, buf):
General Comments 0
You need to be logged in to leave comments. Login now