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

Method __init__

tools/python-3.11.9-amd64/Lib/chunk.py:56–80  ·  view source on GitHub ↗
(self, file, align=True, bigendian=True, inclheader=False)

Source from the content-addressed store, hash-verified

54
55class Chunk:
56 def __init__(self, file, align=True, bigendian=True, inclheader=False):
57 import struct
58 self.closed = False
59 self.align = align # whether to align to word (2-byte) boundaries
60 if bigendian:
61 strflag = '>'
62 else:
63 strflag = '<'
64 self.file = file
65 self.chunkname = file.read(4)
66 if len(self.chunkname) < 4:
67 raise EOFError
68 try:
69 self.chunksize = struct.unpack_from(strflag+'L', file.read(4))[0]
70 except struct.error:
71 raise EOFError from None
72 if inclheader:
73 self.chunksize = self.chunksize - 8 # subtract header
74 self.size_read = 0
75 try:
76 self.offset = self.file.tell()
77 except (AttributeError, OSError):
78 self.seekable = False
79 else:
80 self.seekable = True
81
82 def getname(self):
83 """Return the name (ID) of the current chunk."""

Callers

nothing calls this directly

Calls 2

readMethod · 0.45
tellMethod · 0.45

Tested by

no test coverage detected