campy.util.strlib module

File: strlib.py

Exports a few useful string functions that are not included by default with Python strings.

campy.util.strlib.bool_to_string(b)[source]
campy.util.strlib.ends_with(string, suffix)[source]
campy.util.strlib.equals_ignore_case(s1, s2)[source]
campy.util.strlib.html_decode(encoded_html)[source]
campy.util.strlib.html_encode(plain_html)[source]
campy.util.strlib.quote_string(string, force_quotes=True)[source]

Returns a copy of the string surrounded by double quotes, converting special characters to escape sequences, as necessary. If the optional parameter force is explicitly set to false, quotes are included in the output only if necessary.

TODO make this more pythonic TODO: bug: doesn’t print non-printing chars to JBE correctly

campy.util.strlib.starts_with(string, prefix)[source]
campy.util.strlib.string_is_bool(string)[source]
campy.util.strlib.string_is_double(string)
campy.util.strlib.string_is_integer(string, radix=10)[source]
campy.util.strlib.string_is_long(string)

The following methods are included only for compatibility with the Stanford CPP Libraries They are redundant with builtin Python functionality, and should almost never be used.

campy.util.strlib.string_is_real(string)[source]
campy.util.strlib.string_needs_quoting(string)[source]

Checks whether the string needs quoting in order to be handled correctly.

campy.util.strlib.url_decode(string)[source]
campy.util.strlib.url_encode(string)[source]