utils.py 文件源码

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

项目:Blib 作者: LucaRood 项目源码 文件源码
def get_file_type(f_path):
    """
    Get the Blib type of a file.

    Args:
        f_path (str): Path to the file to be checked.

    Returns:
        str or None
        A string containing the Blib type is returned,
        if no valid type is found, None is returned.
    """

    try:
        archive = zf.ZipFile(f_path, 'r')
    except zf.BadZipFile:
        return None

    try:
        blib_type = archive.comment.decode("utf-8").split(" ")[1]
    except ValueError:
        return None

    archive.close()
    return blib_type
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号