mirror of
https://github.com/openwrt/packages.git
synced 2026-04-15 19:02:09 +00:00
Changes since 2.0.0: - Improve error messages for invalid ini files - Drop support for Python 3.7, add Python 3.12/3.13 Also add test.sh to verify version and basic INI parsing. Link: https://github.com/pytest-dev/iniconfig/blob/main/CHANGELOG Signed-off-by: Alexandru Ardelean <alex@shruggie.ro>
28 lines
735 B
Bash
Executable File
28 lines
735 B
Bash
Executable File
#!/bin/sh
|
|
|
|
[ "$1" = "python3-iniconfig" ] || exit 0
|
|
|
|
python3 - << EOF
|
|
import sys
|
|
import iniconfig
|
|
import tempfile, os
|
|
|
|
# Write a simple INI file and parse it
|
|
ini = "[section1]\nkey1 = value1\nkey2 = 42\n\n[section2]\nflag = true\n"
|
|
with tempfile.NamedTemporaryFile(mode="w", suffix=".ini", delete=False) as f:
|
|
f.write(ini)
|
|
tmp = f.name
|
|
|
|
try:
|
|
cfg = iniconfig.IniConfig(tmp)
|
|
assert cfg["section1"]["key1"] == "value1", "key1 mismatch"
|
|
assert cfg["section1"]["key2"] == "42", "key2 mismatch"
|
|
assert cfg["section2"]["flag"] == "true", "flag mismatch"
|
|
assert "section1" in cfg, "section1 not found"
|
|
assert "missing" not in cfg, "missing section should not exist"
|
|
finally:
|
|
os.unlink(tmp)
|
|
|
|
sys.exit(0)
|
|
EOF
|