wltrace.py 文件源码

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

项目:wltrace 作者: jhshi 项目源码 文件源码
def load_trace(path, *args, **kwargs):
    """Read a packet trace file, return a :class:`wltrace.common.WlTrace` object.

    This function first reads the file's magic
    (first ``FILE_TYPE_HANDLER`` bytes), and automatically determine the
    file type, and call appropriate handler to process the file.

    Args:
        path (str): the file's path to be loaded.

    Returns:
        ``WlTrace`` object.
    """
    with open(path, 'rb') as f:
        magic = f.read(MAGIC_LEN)
    if magic not in FILE_TYPE_HANDLER:
        raise Exception('Unknown file magic: %s' % (binascii.hexlify(magic)))

    return FILE_TYPE_HANDLER[magic](path, *args, **kwargs)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号