summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVictor Shyba <victor1984@riseup.net>2016-11-16 21:57:26 -0300
committerVictor Shyba <victor1984@riseup.net>2016-11-18 15:55:52 -0300
commit9df970cd15365dd1053911ab6d06bddc3c1beb58 (patch)
tree1158ea97bfe35a0d110231cebba0973ced1ec32d
parent12ec7596730e1856099d6ce2a3dab9cde256b093 (diff)
[refactor] simplify content as a new line
Code was complex and raised a flag during review.
-rw-r--r--client/src/leap/soledad/client/http_target/support.py13
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):