From dc8283e51a2b18bdbffb4c4ef26eff0263e3ae3d Mon Sep 17 00:00:00 2001 From: Eran Date: Wed, 22 Mar 2023 08:47:26 +0200 Subject: [PATCH] add shorten_json_string to pyrsutils --- third-party/rsutils/py/pyrsutils.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/third-party/rsutils/py/pyrsutils.cpp b/third-party/rsutils/py/pyrsutils.cpp index f5cbff3d77..8e852fd3e3 100644 --- a/third-party/rsutils/py/pyrsutils.cpp +++ b/third-party/rsutils/py/pyrsutils.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -30,6 +31,18 @@ PYBIND11_MODULE(NAME, m) { py::arg( "logger" ) = LIBREALSENSE_ELPP_ID ); m.def( "split", &rsutils::string::split ); + m.def( + "shorten_json_string", + []( std::string const & str, size_t max_length ) + { return rsutils::string::shorten_json_string( str, max_length ).to_string(); }, + py::arg( "string" ), + py::arg( "max-length" ) = 96 ); + m.def( + "shorten_json_string", + []( nlohmann::json const & j, size_t max_length ) + { return rsutils::string::shorten_json_string( j.dump(), max_length ).to_string(); }, + py::arg( "json" ), + py::arg( "max-length" ) = 96 ); m.def( "executable_path", &rsutils::os::executable_path ); m.def( "executable_name", &rsutils::os::executable_name, py::arg( "with_extension" ) = false );