Flush and close the file. May be called more than once without error. Once the file is closed, any other operation on it will raise a ValueError.
(self)
| 132 | self._buffer = io.BufferedReader(raw) |
| 133 | |
| 134 | def close(self): |
| 135 | """Flush and close the file. |
| 136 | |
| 137 | May be called more than once without error. Once the file is |
| 138 | closed, any other operation on it will raise a ValueError. |
| 139 | """ |
| 140 | if self.closed: |
| 141 | return |
| 142 | try: |
| 143 | if self._mode == _MODE_READ: |
| 144 | self._buffer.close() |
| 145 | self._buffer = None |
| 146 | elif self._mode == _MODE_WRITE: |
| 147 | self._fp.write(self._compressor.flush()) |
| 148 | self._compressor = None |
| 149 | finally: |
| 150 | try: |
| 151 | if self._closefp: |
| 152 | self._fp.close() |
| 153 | finally: |
| 154 | self._fp = None |
| 155 | self._closefp = False |
| 156 | |
| 157 | @property |
| 158 | def closed(self): |