RPM Macro Expansion in Python
Project description
RPM Macro Expansion in Python
Parse RPM macro files and spec files, and expand macros safely—without the potential Turing-Complete side effects.
This is a standalone library that depends only on the standard Python library and PLY (for expression parsing).
How to Use It
$ norpm-expand-specfile --specfile SPEC --expand-string '%version %{!?epoch:(none)}'
1.1.1 (none)
Directly from Python, you can use:
from norpm.macrofile import system_macro_registry
from norpm.specfile import specfile_expand
registry = system_macro_registry()
registry["dist"] = ""
with open("my.spec", "r", encoding="utf8") as fd:
expanded_specfile = specfile_expand(fd.read(), registry)
print("Name:", registry["name"].value)
print("Version:", registry["version"].value)
State of the implementation
There still are a few features to be implemented. Your contributions are welcome and greatly encouraged!
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
norpm-1.4.tar.gz
(45.4 kB
view details)
File details
Details for the file norpm-1.4.tar.gz.
File metadata
- Download URL: norpm-1.4.tar.gz
- Upload date:
- Size: 45.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f843808b2a0250e576700bece57251407d7ddf7f3332d4ef97acf093b734714d
|
|
| MD5 |
3389d61f7ad7cb20ad903c0b42d1c538
|
|
| BLAKE2b-256 |
aa0f13560db2e9f32e6d052add62b70f2fce368f62b129d7502c4a470f085dab
|