python: implement formula.__format__
Fixes #105. * src/bin/common_trans.cc (quote_shell_string): Move ... * src/misc/escape.cc, src/misc/escape.hh (quote_shell_string): ... here. * wrap/python/spot_impl.i: Wrap escape.hh. * wrap/python/spot.py: Implement formula.__format__. * wrap/python/tests/ltlsimple.py: Test it. * NEWS, doc/org/tut01.org, wrap/python/tests/formulas.ipynb: Document it.
This commit is contained in:
parent
20bb171904
commit
5bfd0267e7
9 changed files with 364 additions and 67 deletions
|
|
@ -93,3 +93,26 @@ def count_g(f):
|
|||
x += 1
|
||||
f.traverse(count_g)
|
||||
assert x == 3
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
# The example from tut01.org
|
||||
|
||||
formula = spot.formula('a U b U "$strange[0]=name"')
|
||||
res = """\
|
||||
Default output: {f}
|
||||
Spin syntax: {f:s}
|
||||
(Spin syntax): {f:sp}
|
||||
Default for shell: echo {f:q} | ...
|
||||
LBT for shell: echo {f:lq} | ...
|
||||
Default for CSV: ...,{f:c},...
|
||||
Wring, centered: {f:w:~^50}""".format(f = formula)
|
||||
|
||||
assert res == """\
|
||||
Default output: a U (b U "$strange[0]=name")
|
||||
Spin syntax: a U (b U ($strange[0]=name))
|
||||
(Spin syntax): (a) U ((b) U ($strange[0]=name))
|
||||
Default for shell: echo 'a U (b U "$strange[0]=name")' | ...
|
||||
LBT for shell: echo 'U "a" U "b" "$strange[0]=name"' | ...
|
||||
Default for CSV: ...,"a U (b U ""$strange[0]=name"")",...
|
||||
Wring, centered: ~~~~~(a=1) U ((b=1) U ("$strange[0]=name"=1))~~~~~"""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue