check response before trying to parse it
This commit is contained in:
parent
743466bf80
commit
5889638627
1 changed files with 16 additions and 9 deletions
25
mcg.py
25
mcg.py
|
@ -577,20 +577,27 @@ class Client(Base):
|
|||
|
||||
def _parse_dict(self, response):
|
||||
dict = {}
|
||||
for line in response:
|
||||
key, value = self._split_line(line)
|
||||
dict[key] = value
|
||||
if response:
|
||||
for line in response:
|
||||
key, value = self._split_line(line)
|
||||
dict[key] = value
|
||||
return dict
|
||||
|
||||
|
||||
def _parse_list(self, response, delimiters):
|
||||
entry = {}
|
||||
for line in response:
|
||||
key, value = self._split_line(line)
|
||||
if entry and key in delimiters:
|
||||
yield entry
|
||||
entry = {}
|
||||
entry[key] = value
|
||||
if response:
|
||||
for line in response:
|
||||
key, value = self._split_line(line)
|
||||
if entry and key in delimiters:
|
||||
yield entry
|
||||
entry = {}
|
||||
#if key in entry.keys():
|
||||
# if entry[key] is not list:
|
||||
# entry[key] = [entry[key]]
|
||||
# entry[key].append(value)
|
||||
#else:
|
||||
entry[key] = value
|
||||
if entry:
|
||||
yield entry
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue