har.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:httpolice 作者: vfaronov 项目源码 文件源码
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)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号