MCPcopy Create free account
hub / github.com/scanny/python-pptx / _Stream

Class _Stream

src/pptx/text/fonts.py:191–223  ·  view source on GitHub ↗

A thin wrapper around a binary file that facilitates reading C-struct values.

Source from the content-addressed store, hash-verified

189
190
191class _Stream(object):
192 """A thin wrapper around a binary file that facilitates reading C-struct values."""
193
194 def __init__(self, file):
195 self._file = file
196
197 @classmethod
198 def open(cls, path):
199 """Return |_Stream| providing binary access to contents of file at `path`."""
200 return cls(open(path, "rb"))
201
202 def close(self):
203 """
204 Close the wrapped file. Using the stream after closing raises an
205 exception.
206 """
207 self._file.close()
208
209 def read(self, offset, length):
210 """
211 Return *length* bytes from this stream starting at *offset*.
212 """
213 self._file.seek(offset)
214 return self._file.read(length)
215
216 def read_fields(self, template, offset=0):
217 """
218 Return a tuple containing the C-struct fields in this stream
219 specified by *template* and starting at *offset*.
220 """
221 self._file.seek(offset)
222 bufr = self._file.read(calcsize(template))
223 return unpack_from(template, bufr)
224
225
226class _BaseTable(object):

Callers 5

iter_fixtureMethod · 0.90
close_fixtureMethod · 0.90
read_fixtureMethod · 0.90
read_flds_fixtureMethod · 0.90
macStyle_fixtureMethod · 0.90

Calls

no outgoing calls

Tested by 5

iter_fixtureMethod · 0.72
close_fixtureMethod · 0.72
read_fixtureMethod · 0.72
read_flds_fixtureMethod · 0.72
macStyle_fixtureMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…