From b9ef460f39a9f0b62894367c4260986e35fbbb1c Mon Sep 17 00:00:00 2001 From: Victor Shyba Date: Wed, 16 Nov 2016 21:57:26 -0300 Subject: [refactor] simplify content as a new line Code was complex and raised a flag during review. --- client/src/leap/soledad/client/http_target/support.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/client/src/leap/soledad/client/http_target/support.py b/client/src/leap/soledad/client/http_target/support.py index 19e07838..d8d8e420 100644 --- a/client/src/leap/soledad/client/http_target/support.py +++ b/client/src/leap/soledad/client/http_target/support.py @@ -162,20 +162,15 @@ class RequestBody(object): def insert_info(self, **entry_dict): """ Dumps an entry into JSON format and add it to entries list. + Adds 'content' key on a new line if it's present. :param entry_dict: Entry as a dictionary :type entry_dict: dict - - :return: length of the entry after JSON dumps - :rtype: int """ + content = '' if 'content' in entry_dict: - content = entry_dict['content'] or '' - del entry_dict['content'] - entry = json.dumps(entry_dict) - entry = entry + ',\r\n' + content - else: - entry = json.dumps(entry_dict) + content = ',\r\n' + (entry_dict['content'] or '') + entry = json.dumps(entry_dict) + content self.entries.append(entry) def pop(self, amount=10, leave_open=False): -- cgit v1.2.3