import numbers


def	fieldsDict_toLineProtocolString(pFieldsDict:dict):
	"""Converts a fields dictionnary to a valid LineProtocol string."""

	retval	=	''

	for lFieldName in pFieldsDict:
		lFieldValue = pFieldsDict[lFieldName]

		if retval != '':
			retval	+= ','

		retval	+= lFieldName
		retval	+= '='
		if isinstance(lFieldValue, numbers.Number):
			# If the field value is considered a number, write it directly
			retval	+= str(lFieldValue)
		else:
			# Otherwise, wrap the field inside double quotes to consider it as
			# a string.
			retval	+= "\"" + str(lFieldValue) + "\""


	return retval