diff options
author | Victor Shyba <victor1984@riseup.net> | 2016-11-16 21:57:26 -0300 |
---|---|---|
committer | drebs <drebs@leap.se> | 2016-12-12 09:12:01 -0200 |
commit | b9ef460f39a9f0b62894367c4260986e35fbbb1c (patch) | |
tree | 01f2b67f6d82e733b52459e4a0c1863688fb4d13 /client | |
parent | d297b54c45271dbb6fd1aa0f3e6fd209220e1038 (diff) |
[refactor] simplify content as a new line
Code was complex and raised a flag during review.
Diffstat (limited to 'client')
-rw-r--r-- | client/src/leap/soledad/client/http_target/support.py | 13 |
1 files 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): |