Resolve suitable defaults from the archive. Resolve the date_time, compression attributes, and external attributes to suitable defaults as used by :method:`ZipFile.writestr`. Return self.
(self, archive)
| 655 | return zinfo |
| 656 | |
| 657 | def _for_archive(self, archive): |
| 658 | """Resolve suitable defaults from the archive. |
| 659 | |
| 660 | Resolve the date_time, compression attributes, and external attributes |
| 661 | to suitable defaults as used by :method:`ZipFile.writestr`. |
| 662 | |
| 663 | Return self. |
| 664 | """ |
| 665 | # gh-91279: Set the SOURCE_DATE_EPOCH to a specific timestamp |
| 666 | epoch = os.environ.get('SOURCE_DATE_EPOCH') |
| 667 | get_time = int(epoch) if epoch else time.time() |
| 668 | self.date_time = time.localtime(get_time)[:6] |
| 669 | |
| 670 | self.compress_type = archive.compression |
| 671 | self.compress_level = archive.compresslevel |
| 672 | if self.filename.endswith('/'): # pragma: no cover |
| 673 | self.external_attr = 0o40775 << 16 # drwxrwxr-x |
| 674 | self.external_attr |= 0x10 # MS-DOS directory flag |
| 675 | else: |
| 676 | self.external_attr = 0o600 << 16 # ?rw------- |
| 677 | return self |
| 678 | |
| 679 | def is_dir(self): |
| 680 | """Return True if this archive member is a directory.""" |