def har_input(paths):
for path in paths:
# According to the spec, HAR files are UTF-8 with an optional BOM.
path = decode_path(path)
with io.open(path, 'rt', encoding='utf-8-sig') as f:
try:
data = json.load(f)
except ValueError as exc:
six.raise_from(
InputError(u'%s: bad HAR file: %s' % (path, exc)),
exc)
try:
creator = data['log']['creator']['name']
for entry in data['log']['entries']:
yield _process_entry(entry, creator, path)
except (TypeError, KeyError) as exc:
six.raise_from(
InputError(u'%s: cannot understand HAR file: %r' %
(path, exc)),
exc)
评论列表
文章目录