class_docstr: Python implementation of a format decoder. Override this class and
  add the decoding logic in the `decode` method.
  
  See :ref:`Writing Your Own File Decoder in Python<file-decoders-py>`
class_docstr_tok: ["Python","implementation","of","a","format","decoder",".","Override","this","class","and","add","the","decoding","logic","in","the","`","decode","`","method",".","See",":","ref",":","`","Writing","Your","Own","File","Decoder","in","Python","<","file-decoders-py",">","`"]
docstr: Convenience method to set the internal image from a stream of raw data
  
  :param data: Bytes to be set
  :param rawmode: The rawmode to be used for the decoder.
      If not specified, it will default to the mode of the image
  :returns: None
docstr_tok: ["Convenience","method","to","set","the","internal","image","from","a","stream","of","raw","data",":","param","data",":","Bytes","to","be","set",":","param","rawmode",":","The","rawmode","to","be","used","for","the","decoder",".","If","not","specified",",","it","will","default","to","the","mode","of","the","image",":","returns",":","None"]
code: def set_as_raw(self, data, rawmode=None):
      """
      Convenience method to set the internal image from a stream of raw data
  
      :param data: Bytes to be set
      :param rawmode: The rawmode to be used for the decoder.
          If not specified, it will default to the mode of the image
      :returns: None
      """
  
      if not rawmode:
          rawmode = self.mode
      d = Image._getdecoder(self.mode, "raw", (rawmode))
      d.setimage(self.im, self.state.extents())
      s = d.decode(data)
  
      if s[0] >= 0:
          raise ValueError("not enough image data")
      if s[1] != 0:
          raise ValueError("cannot decode image data")
  
imports: import io
  import struct
  import sys
  from .None import Image
  from ._util import isPath
label_desc: Use image node_id 8 for calling the PyDecoder obj's underlying member method code with example usage: obj.set_as_raw(data, rawmode) without return types