MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / ZipInfo

Class ZipInfo

tools/python-3.11.9-amd64/Lib/zipfile.py:346–570  ·  view source on GitHub ↗

Class with attributes describing each file in the ZIP archive.

Source from the content-addressed store, hash-verified

344
345
346class ZipInfo (object):
347 """Class with attributes describing each file in the ZIP archive."""
348
349 __slots__ = (
350 'orig_filename',
351 'filename',
352 'date_time',
353 'compress_type',
354 '_compresslevel',
355 'comment',
356 'extra',
357 'create_system',
358 'create_version',
359 'extract_version',
360 'reserved',
361 'flag_bits',
362 'volume',
363 'internal_attr',
364 'external_attr',
365 'header_offset',
366 'CRC',
367 'compress_size',
368 'file_size',
369 '_raw_time',
370 '_end_offset',
371 )
372
373 def __init__(self, filename="NoName", date_time=(1980,1,1,0,0,0)):
374 self.orig_filename = filename # Original file name in archive
375
376 # Terminate the file name at the first null byte. Null bytes in file
377 # names are used as tricks by viruses in archives.
378 null_byte = filename.find(chr(0))
379 if null_byte >= 0:
380 filename = filename[0:null_byte]
381 # This is used to ensure paths in generated ZIP files always use
382 # forward slashes as the directory separator, as required by the
383 # ZIP format specification.
384 if os.sep != "/" and os.sep in filename:
385 filename = filename.replace(os.sep, "/")
386
387 self.filename = filename # Normalized file name
388 self.date_time = date_time # year, month, day, hour, min, sec
389
390 if date_time[0] < 1980:
391 raise ValueError('ZIP does not support timestamps before 1980')
392
393 # Standard values:
394 self.compress_type = ZIP_STORED # Type of compression for the file
395 self._compresslevel = None # Level for the compressor
396 self.comment = b"" # Comment for each file
397 self.extra = b"" # ZIP extra data
398 if sys.platform == 'win32':
399 self.create_system = 0 # System which created ZIP archive
400 else:
401 # Assume everything else is unix-y
402 self.create_system = 3 # System which created ZIP archive
403 self.create_version = DEFAULT_VERSION # Version which created ZIP archive

Callers 6

_write_scriptMethod · 0.90
_RealGetContentsMethod · 0.85
openMethod · 0.85
writestrMethod · 0.85
mkdirMethod · 0.85
getinfoMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected