Class to add a close hook to an open file.
| 35 | |
| 36 | |
| 37 | class addclosehook(addbase): |
| 38 | """Class to add a close hook to an open file.""" |
| 39 | |
| 40 | def __init__(self, fp, closehook, *hookargs): |
| 41 | super(addclosehook, self).__init__(fp) |
| 42 | self.closehook = closehook |
| 43 | self.hookargs = hookargs |
| 44 | |
| 45 | def close(self): |
| 46 | try: |
| 47 | closehook = self.closehook |
| 48 | hookargs = self.hookargs |
| 49 | if closehook: |
| 50 | self.closehook = None |
| 51 | self.hookargs = None |
| 52 | closehook(*hookargs) |
| 53 | finally: |
| 54 | super(addclosehook, self).close() |
| 55 | |
| 56 | |
| 57 | class addinfo(addbase): |
no outgoing calls
no test coverage detected
searching dependent graphs…