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:
Alexandre Duret-Lutz 2015-10-03 11:20:02 +02:00
parent 20bb171904
commit 5bfd0267e7
9 changed files with 364 additions and 67 deletions

View file

@ -65,5 +65,13 @@ namespace spot
/// \brief Remove spaces at the front and back of \a str.
SPOT_API void
trim(std::string& str);
/// \brief Output \a str between simple quote or double quotes
///
/// Simple quotes are preferred unless \a str contains some simple
/// quotes. In that case we use double quotes and escape anything
/// that needs to be escaped.
SPOT_API std::ostream&
quote_shell_string(std::ostream& os, const char* str);
/// @}
}