(self, data: bytes)
Incrementally decodes JSON data sets into Python objects.
		
		Raises
		------
		~ipfshttpclient.exceptions.DecodingError
Incrementally decodes JSON data sets into Python objects.
		
		Raises
		------
		~ipfshttpclient.exceptions.DecodingError
Incrementally decodes JSON data sets into Python objects . Raises ------ ~ipfshttpclient . exceptions . DecodingError
def parse_partial(self, data: bytes) -> ty.Generator[utils.json_value_t, ty.Any, ty.Any]:
		"""Incrementally decodes JSON data sets into Python objects.
		
		Raises
		------
		~ipfshttpclient.exceptions.DecodingError
		"""
		try:
			# Python requires all JSON data to text strings
			lines = self._decoder1.decode(data, False).split("\n")
			
			# Add first input line to last buffer line, if applicable, to
			# handle cases where the JSON string has been chopped in half
			# at the network level due to streaming
			if len(self._buffer) > 0 and self._buffer[-1] is not None:
				self._buffer[-1] += lines[0]
				self._buffer.extend(lines[1:])
			else:
				self._buffer.extend(lines)
		except UnicodeDecodeError as error:
			raise exceptions.DecodingError('json', error) from error
		
		# Process data buffer
		index = 0
		try:
			# Process each line as separate buffer
			#PERF: This way the `.lstrip()` call becomes almost always a NOP
			#      even if it does return a different string it will only
			#      have to allocate a new buffer for the currently processed
			#      line.
			while index < len(self._buffer):
				while self._buffer[index]:
					# Make sure buffer does not start with whitespace
					#PERF: `.lstrip()` does not reallocate if the string does
					#      not actually start with whitespace.
					self._buffer[index] = self._buffer[index].lstrip()
					
					# Handle case where the remainder of the line contained
					# only whitespace
					if not self._buffer[index]:
						self._buffer[index] = None
						continue
					
					# Try decoding the partial data buffer and return results
					# from this
					#
					# Use `pragma: no branch` as the final loop iteration will always
					# raise if parsing didn't work out, rather then falling through
					# to the `yield obj` line.
					data = self._buffer[index]
					for index2 in range(index, len(self._buffer)):  # pragma: no branch
						# If decoding doesn't succeed with the currently
						# selected buffer (very unlikely with our current
						# class of input data) then retry with appending
						# any other pending pieces of input data
						# This will happen with JSON data that contains
						# arbitrary new-lines: "{1:\n2,\n3:4}"
						if index2 > index:
							data += "\n" + self._buffer[index2]
						
						try:
							(obj, offset) = self._decoder2.raw_decode(data)
						except ValueError:
							# Treat error as fatal if we have already added
							# the final buffer to the input
							if (index2 + 1) == len(self._buffer):
								raise
						else:
							index = index2
							break
					
					# Decoding succeeded – yield result and shorten buffer
					yield obj
					if offset < len(self._buffer[index]):
						self._buffer[index] = self._buffer[index][offset:]
					else:
						self._buffer[index] = None
				index += 1
		except ValueError as error:
			# It is unfortunately not possible to reliably detect whether
			# parsing ended because of an error *within* the JSON string, or
			# an unexpected *end* of the JSON string.
			# We therefor have to assume that any error that occurs here
			# *might* be related to the JSON parser hitting EOF and therefor
			# have to postpone error reporting until `parse_finalize` is
			# called.
			self._lasterror = error
		finally:
			# Remove all processed buffers
			del self._buffer[0:index]
def parse_partial ( self , data : bytes ) -> ty . Generator [ utils . json_value_t , ty . Any , ty . Any ] : try : # Python requires all JSON data to text strings lines = self . _decoder1 . decode ( data , False ) . split ( "\n" ) # Add first input line to last buffer line, if applicable, to # handle cases where the JSON string has been chopped in half # at the network level due to streaming if len ( self . _buffer ) > 0 and self . _buffer [ - 1 ] is not None : self . _buffer [ - 1 ] += lines [ 0 ] self . _buffer . extend ( lines [ 1 : ] ) else : self . _buffer . extend ( lines ) except UnicodeDecodeError as error : raise exceptions . DecodingError ( 'json' , error ) from error # Process data buffer index = 0 try : # Process each line as separate buffer #PERF: This way the `.lstrip()` call becomes almost always a NOP #      even if it does return a different string it will only #      have to allocate a new buffer for the currently processed #      line. while index < len ( self . _buffer ) : while self . _buffer [ index ] : # Make sure buffer does not start with whitespace #PERF: `.lstrip()` does not reallocate if the string does #      not actually start with whitespace. self . _buffer [ index ] = self . _buffer [ index ] . lstrip ( ) # Handle case where the remainder of the line contained # only whitespace if not self . _buffer [ index ] : self . _buffer [ index ] = None continue # Try decoding the partial data buffer and return results # from this # # Use `pragma: no branch` as the final loop iteration will always # raise if parsing didn't work out, rather then falling through # to the `yield obj` line. data = self . _buffer [ index ] for index2 in range ( index , len ( self . _buffer ) ) : # pragma: no branch # If decoding doesn't succeed with the currently # selected buffer (very unlikely with our current # class of input data) then retry with appending # any other pending pieces of input data # This will happen with JSON data that contains # arbitrary new-lines: "{1:\n2,\n3:4}" if index2 > index : data += "\n" + self . _buffer [ index2 ] try : ( obj , offset ) = self . _decoder2 . raw_decode ( data ) except ValueError : # Treat error as fatal if we have already added # the final buffer to the input if ( index2 + 1 ) == len ( self . _buffer ) : raise else : index = index2 break # Decoding succeeded – yield result and shorten buffer yield obj if offset < len ( self . _buffer [ index ] ) : self . _buffer [ index ] = self . _buffer [ index ] [ offset : ] else : self . _buffer [ index ] = None index += 1 except ValueError as error : # It is unfortunately not possible to reliably detect whether # parsing ended because of an error *within* the JSON string, or # an unexpected *end* of the JSON string. # We therefor have to assume that any error that occurs here # *might* be related to the JSON parser hitting EOF and therefor # have to postpone error reporting until `parse_finalize` is # called. self . _lasterror = error finally : # Remove all processed buffers del self . _buffer [ 0 : index ]