multiarchive 0.2.3__tar.gz → 0.2.5__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: multiarchive
3
- Version: 0.2.3
3
+ Version: 0.2.5
4
4
  Summary: A high level archive handler for Python.
5
5
  Author: NSPC911
6
6
  Author-email: NSPC911 <87571998+NSPC911@users.noreply.github.com>
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "multiarchive"
3
- version = "0.2.3"
3
+ version = "0.2.5"
4
4
  description = "A high level archive handler for Python."
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.11"
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "multiarchive"
3
- version = "0.2.3"
3
+ version = "0.2.5"
4
4
  description = "A high level archive handler for Python."
5
5
  readme = "README.md"
6
6
  authors = [
@@ -141,7 +141,10 @@ class ArchiveMemberInfo:
141
141
 
142
142
  @classmethod
143
143
  def from_zipinfo(cls, info: zipfile.ZipInfo) -> "ArchiveMemberInfo":
144
- mtime_dt = datetime(*info.date_time)
144
+ try:
145
+ mtime_dt = datetime(*info.date_time)
146
+ except ValueError:
147
+ mtime_dt = datetime(1980, 1, 1)
145
148
  return cls(
146
149
  name=info.filename,
147
150
  uncompressed_size=info.file_size,
@@ -194,7 +197,10 @@ class ArchiveMemberInfo:
194
197
  if info.mtime is not None:
195
198
  mtime = info.mtime.timestamp()
196
199
  elif info.date_time is not None:
197
- mtime = datetime(*info.date_time).timestamp()
200
+ try:
201
+ mtime = datetime(*info.date_time).timestamp()
202
+ except ValueError:
203
+ mtime = 0.0
198
204
  else:
199
205
  mtime = 0.0
200
206
  assert info.filename is not None
@@ -257,7 +263,7 @@ class Archive:
257
263
  mode: File access mode ('r' for read, 'w' for write, 'a' for append)
258
264
  compression_level: Compression level (ZIP: 0-9, TAR gzip: 0-9, TAR bzip2: 1-9)
259
265
  If None, uses default compression
260
- pwd: Password for opening an encrypted file
266
+ pwd: Password for reading an encrypted ZIP file
261
267
  strict_timestamps: If True, reject timestamps outside the range supported
262
268
  by ZIP; if False, clamp them to the minimum or maximum supported value
263
269
 
@@ -296,7 +302,7 @@ class Archive:
296
302
  algo: Optional override for archive type based on file extension
297
303
  mode: File access mode ('r' for read, 'w' for write, 'a' for append)
298
304
  compression_level: Compression level (ZIP: 0-9, TAR gzip: 0-9, TAR bzip2: 1-9)
299
- pwd: Password for opening an encrypted file
305
+ pwd: Password for reading an encrypted ZIP file
300
306
  strict_timestamps: If True, reject timestamps outside the range supported
301
307
  by ZIP; if False, clamp them to the minimum or maximum supported value
302
308
 
@@ -487,6 +493,9 @@ class Archive:
487
493
  Raises:
488
494
  ValueError: If file extension is not recognized or compression_level is invalid
489
495
  """
496
+ if self.pwd is not None:
497
+ raise ValueError("Passwords are only supported when reading ZIP files")
498
+
490
499
  filename_lower = self.filename.lower()
491
500
 
492
501
  if (
@@ -772,7 +781,7 @@ class Archive:
772
781
 
773
782
  Args:
774
783
  member: Name of the file to open, or ZipInfo/TarInfo/RarInfo object
775
- mode: File open mode (only 'r' supported for non-TAR compressed and RAR files)
784
+ mode: File open mode (only 'r' supported for TAR and RAR files)
776
785
 
777
786
  Returns:
778
787
  File-like object for reading the member's contents, or None if member
File without changes