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
7
mcg.py
7
mcg.py
|
|
@ -577,6 +577,7 @@ class Client(Base):
|
||||||
|
|
||||||
def _parse_dict(self, response):
|
def _parse_dict(self, response):
|
||||||
dict = {}
|
dict = {}
|
||||||
|
if response:
|
||||||
for line in response:
|
for line in response:
|
||||||
key, value = self._split_line(line)
|
key, value = self._split_line(line)
|
||||||
dict[key] = value
|
dict[key] = value
|
||||||
|
|
@ -585,11 +586,17 @@ class Client(Base):
|
||||||
|
|
||||||
def _parse_list(self, response, delimiters):
|
def _parse_list(self, response, delimiters):
|
||||||
entry = {}
|
entry = {}
|
||||||
|
if response:
|
||||||
for line in response:
|
for line in response:
|
||||||
key, value = self._split_line(line)
|
key, value = self._split_line(line)
|
||||||
if entry and key in delimiters:
|
if entry and key in delimiters:
|
||||||
yield entry
|
yield entry
|
||||||
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
|
entry[key] = value
|
||||||
if entry:
|
if entry:
|
||||||
yield entry
|
yield entry
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue