使用libmagic和Pygments进行综合的文件类型和MIME类型检测。
项目描述
许可协议:Apache-2.0
版权:版权(C)nexB. Inc. 和其他
主页:[https://github.com/nexB/typecode](https://github.com/nexB/typecode)(rel="nofollow")
关键词:文件类型,MIME类型,libmagic,scancode-toolkit,typecode
TypeCode 使用多个检测器(包括 libmagic,作为 Linux、Windows 和 macOS 的依赖项包含)和 Pygments 提供全面的文件类型和 MIME 类型检测。它最初是 scancode-toolkit 中的一个库。访问 [https://aboutcode.org](https://aboutcode.org) 和 [https://github.com/nexB/](https://github.com/nexB/) 获取支持并下载。
我们在以下平台上运行 CI 测试:
Travis [https://travis-ci.org/github/nexB/typecode](https://travis-ci.org/github/nexB/typecode)(rel="nofollow")
Azure pipelines [https://dev.azure.com/nexB/typecode/_build](https://dev.azure.com/nexB/typecode/_build)(rel="nofollow")
要使用完整功能安装此包(其中包含 libmagic 的二进制文件),请使用 full 选项
pip install typecode[full]
如果您想使用操作系统提供的 libmagic 版本(可能是),请使用 minimal 选项
pip install typecode
在这种情况下,您需要以以下一种方式提供可用的 libmagic 和其数据库
typecode-libmagic 插件:请参阅标准插件,见 https://github.com/nexB/scancode-plugins/tree/main/builtins 这些插件可以捆绑 libmagic 库及其 magic 数据库或公开系统安装的 libmagic。它们通过为 typecode_libmagic 提供 scancode_location_provider 作为插件入口点来实现,该入口点指向必须返回包含以下两个键的映射的可调用对象
‘typecode.libmagic.dll’:libmagic DLL 的绝对路径
‘typecode.libmagic.db’:libmagic ‘magic.mgc’ 数据库的绝对路径
例如
环境变量:
TYPECODE_LIBMAGIC_PATH:libmagic DLL 的绝对路径
TYPECODE_LIBMAGIC_DB_PATH:libmagic ‘magic.mgc’ 数据库的绝对路径
系统路径中可用的系统安装的 libmagic 和其数据库:
支持的 libmagic 版本是 5.39。
设置开发环境
source configure --dev
运行单元测试
pytest -vvs -n 2
清理开发环境
./configure --clean
要更新 Pygment 到较新的供应商版本,请使用 vendy
更新 pyproject.toml 中的 pygments 版本
运行 vendy
相应地更新 src/typecpde/pygments_lexers_mapping.py 和 src/typecode/pygments_lexers.py 脚本,包括它们的 ABOUT 文件
项目详情
下载文件
下载适用于您平台的文件。如果您不确定选择哪个,请了解有关 安装包 的更多信息。