Skip to content

Commit e30ed3e

Browse files
committed
Fix formatting
1 parent 520c748 commit e30ed3e

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

provider/consumer.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ def __fireTrigger(self, messages):
463463
# return the dict that will be sent as the trigger payload
464464
def __getMessagePayload(self, message):
465465
return {
466-
'value': self.__encodeMessageIfNeeded(message.value()),
466+
'value': self.encodeMessageIfNeeded(message.value()),
467467
'topic': message.topic(),
468468
'partition': message.partition(),
469469
'offset': message.offset(),
@@ -501,8 +501,8 @@ def __getUTF8Encoding(self, value):
501501
return value
502502

503503

504-
def __encodeMessageIfNeeded(self, value):
505-
value = self.__getUTF8Encoding(value)
504+
def __encodeMessageIfNeeded(self, value):
505+
value = self.getUTF8Encoding(value)
506506

507507
if self.encodeValueAsJSON:
508508
try:
@@ -512,8 +512,8 @@ def __encodeMessageIfNeeded(self, value):
512512
except ValueError as e:
513513
# message is not a JSON object, return the message as a JSON value
514514
logging.warn('[{}] I was asked to encode a message as JSON, but I failed with "{}".'.format(self.trigger, e))
515-
value = self.__getUTF8Encoding("\"{}\"".format(value))
516-
pass
515+
value = "\"{}\"".format(value)
516+
return value
517517
elif self.encodeValueAsBase64:
518518
try:
519519
parsed = value.encode("base64").strip()
@@ -536,6 +536,8 @@ def __encodeKeyIfNeeded(self, key):
536536
logging.warn('[{}] Unable to encode a binary key.'.format(self.trigger))
537537
pass
538538

539+
key = self.getUTF8Encoding(key)
540+
539541
logging.debug('[{}] Returning un-encoded message'.format(self.trigger))
540542
return key
541543

0 commit comments

Comments
 (0)