Close the _Stream object. No operation should be done on it afterwards.
(self)
| 458 | self.buf = self.buf[self.bufsize:] |
| 459 | |
| 460 | def close(self): |
| 461 | """Close the _Stream object. No operation should be |
| 462 | done on it afterwards. |
| 463 | """ |
| 464 | if self.closed: |
| 465 | return |
| 466 | |
| 467 | self.closed = True |
| 468 | try: |
| 469 | if self.mode == "w" and self.comptype != "tar": |
| 470 | self.buf += self.cmp.flush() |
| 471 | |
| 472 | if self.mode == "w" and self.buf: |
| 473 | self.fileobj.write(self.buf) |
| 474 | self.buf = b"" |
| 475 | if self.comptype == "gz": |
| 476 | self.fileobj.write(struct.pack("<L", self.crc)) |
| 477 | self.fileobj.write(struct.pack("<L", self.pos & 0xffffFFFF)) |
| 478 | finally: |
| 479 | if not self._extfileobj: |
| 480 | self.fileobj.close() |
| 481 | |
| 482 | def _init_read_gz(self): |
| 483 | """Initialize for reading a gzip compressed fileobj. |