if errorcode == 200 and fmt != 'debug':
getattr(self, '_parse_' + fmt)()
- else:
- print("Bad response: ", page)
def _parse_json(self):
m = re.fullmatch(r'([\w$][^(]*)\((.*)\)', self.page)
self.header['json_func'] = m.group(1)
self.result = json.JSONDecoder(object_pairs_hook=OrderedDict).decode(code)
if isinstance(self.result, OrderedDict):
- self.result = [self.result]
+ if 'error' in self.result:
+ self.result = []
+ else:
+ self.result = [self.result]
def _parse_geojson(self):
self._parse_json()
- if 'error' in self.result[0]:
- self.result = []
- else:
+ if self.result:
self.result = list(map(_geojson_result_to_json_result, self.result[0]['features']))
def _parse_geocodejson(self):
elif value.startswith("^"):
assert re.fullmatch(value, self.result[idx][field]), \
BadRowValueAssert(self, idx, field, value)
+ elif isinstance(self.result[idx][field], OrderedDict):
+ assert self.result[idx][field] == eval('{' + value + '}'), \
+ BadRowValueAssert(self, idx, field, value)
else:
assert str(self.result[idx][field]) == str(value), \
BadRowValueAssert(self, idx, field, value)