读取 rpm 归档文件
项目描述
rpm文件
在 python 中检查 RPM 文件的工具。该模块以 tarfile模块为模型。
安装
$ python -m pip install -U rpmfile
如果您想使用rpmfile
压缩的zstd
rpm,您需要安装 zstandard模块。
zstd
还要求您使用 Python >= 3.5
$ python -m pip install -U zstandard
例子
有关更多示例,请参阅测试。
import rpmfile
with rpmfile.open('file.rpm') as rpm:
# Inspect the RPM headers
print(rpm.headers.keys())
print(rpm.headers.get('arch', 'noarch'))
# Extract a fileobject from the archive
fd = rpm.extractfile('./usr/bin/script')
print(fd.read())
for member in rpm.getmembers():
print(member)
命令行使用
如果您的环境变量配置正确,您可以rpmfile
通过它的模块调用或rpmfile
命令使用。PATH
通过--help
所有选项。
列出 RPM 内容
curl -sfL 'https://example.com/some.rpm.gz' | gzip -d - | python -m rpmfile -l -
./path/to/file
提取文件
curl -sfL 'https://example.com/some.rpm.gz' | gzip -d - | rpmfile -xv -
./path/to/file
提取文件到目录
curl -sfL 'https://example.com/some.rpm.gz' | gzip -d - | rpmfile -xvC /tmp -
/tmp/path/to/file
课程
- rpmfile.RPMFile:RPMFile 对象提供了一个到 RPM 存档的接口
- rpmfile.RPMInfo:RPMInfo 对象代表 RPMFile 中的一个成员。
贡献
在提交贡献之前,应在所有文件上使用黑色格式化程序。版本 19.10b0。
$ pip install black==19.10b0
$ black .
这个模块中的代码是从以下地方借来的:
项目详情
下载文件
下载适用于您平台的文件。如果您不确定要选择哪个,请了解有关安装包的更多信息。
源分布
rpmfile-1.0.8.tar.gz
(19.6 kB
查看哈希)
内置分布
rpmfile-1.0.8-py3-none-any.whl
(19.4 kB
查看哈希)