MCPcopy Index your code
hub / github.com/plotly/plotly.py / __init__

Method __init__

_plotly_utils/png.py:1308–1356  ·  view source on GitHub ↗

The constructor expects exactly one keyword argument. If you supply a positional argument instead, it will guess the input type. Choose from the following keyword arguments: filename Name of input file (a PNG file). file A file-li

(self, _guess=None, filename=None, file=None, bytes=None)

Source from the content-addressed store, hash-verified

1306 """
1307
1308 def __init__(self, _guess=None, filename=None, file=None, bytes=None):
1309 """
1310 The constructor expects exactly one keyword argument.
1311 If you supply a positional argument instead,
1312 it will guess the input type.
1313 Choose from the following keyword arguments:
1314
1315 filename
1316 Name of input file (a PNG file).
1317 file
1318 A file-like object (object with a read() method).
1319 bytes
1320 ``bytes`` or ``bytearray`` with PNG data.
1321
1322 """
1323 keywords_supplied = (
1324 (_guess is not None)
1325 + (filename is not None)
1326 + (file is not None)
1327 + (bytes is not None)
1328 )
1329 if keywords_supplied != 1:
1330 raise TypeError("Reader() takes exactly 1 argument")
1331
1332 # Will be the first 8 bytes, later on. See validate_signature.
1333 self.signature = None
1334 self.transparent = None
1335 # A pair of (len,type) if a chunk has been read but its data and
1336 # checksum have not (in other words the file position is just
1337 # past the 4 bytes that specify the chunk type).
1338 # See preamble method for how this is used.
1339 self.atchunk = None
1340
1341 if _guess is not None:
1342 if isarray(_guess):
1343 bytes = _guess
1344 elif isinstance(_guess, str):
1345 filename = _guess
1346 elif hasattr(_guess, "read"):
1347 file = _guess
1348
1349 if bytes is not None:
1350 self.file = io.BytesIO(bytes)
1351 elif filename is not None:
1352 self.file = open(filename, "rb")
1353 elif file is not None:
1354 self.file = file
1355 else:
1356 raise ProtocolError("expecting filename, file or bytes array")
1357
1358 def chunk(self, lenient=False):
1359 """

Callers

nothing calls this directly

Calls 2

isarrayFunction · 0.85
ProtocolErrorClass · 0.85

Tested by

no test coverage detected