(self, path)
Gross hack to contort loader to deal w/ load_*()'s bad API.
Gross hack to contort loader to deal w/ load_*()'s bad API.
Gross hack to contort loader to deal w / load_ * () s bad API .
def get_data(self, path):
        """Gross hack to contort loader to deal w/ load_*()'s bad API."""
        if self.file and path == self.path:
            # The contract of get_data() requires us to return bytes. Reopen the
            # file in binary mode if needed.
            if not self.file.closed:
                file = self.file
                if 'b' not in file.mode:
                    file.close()
            if self.file.closed:
                self.file = file = open(self.path, 'rb')

            with file:
                return file.read()
        else:
            return super().get_data(path)
def get_data ( self , path ) : if self . file and path == self . path : # The contract of get_data() requires us to return bytes. Reopen the # file in binary mode if needed. if not self . file . closed : file = self . file if 'b' not in file . mode : file . close ( ) if self . file . closed : self . file = file = open ( self . path , 'rb' ) with file : return file . read ( ) else : return super ( ) . get_data ( path )