mirror of
https://github.com/openwrt/packages.git
synced 2026-04-16 11:22:16 +00:00
pyparsing also requires the 'unittest' module from the Python3 package. Changelog: https://github.com/pyparsing/pyparsing/blob/master/CHANGES Signed-off-by: Alexandru Ardelean <alex@shruggie.ro>
31 lines
592 B
Bash
Executable File
31 lines
592 B
Bash
Executable File
#!/bin/sh
|
|
|
|
[ "$1" = python3-pyparsing ] || exit 0
|
|
|
|
python3 - << 'EOF'
|
|
|
|
import pyparsing as pp
|
|
|
|
# Basic word and integer parsing
|
|
word = pp.Word(pp.alphas)
|
|
integer = pp.Word(pp.nums)
|
|
|
|
result = word.parse_string("hello")
|
|
assert result[0] == "hello"
|
|
|
|
result = integer.parse_string("42")
|
|
assert result[0] == "42"
|
|
|
|
# Combined expression
|
|
greeting = word + pp.Literal(",") + word
|
|
result = greeting.parse_string("Hello, World")
|
|
assert result[0] == "Hello"
|
|
assert result[2] == "World"
|
|
|
|
# OneOf
|
|
colors = pp.one_of("red green blue")
|
|
result = colors.parse_string("green")
|
|
assert result[0] == "green"
|
|
|
|
EOF
|