From 0ccd55e33f8bcdbba136699b52241a7dcc6bf305 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 29 Mar 2021 10:50:32 +0200 Subject: [PATCH] [libcalamares] Warn (python only) about unknown GS keys This makes it easier to spot problems where key-names are mis-spelled in Python (or other modules change a name and it's not applied to consumers) --- src/libcalamares/PythonHelper.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/libcalamares/PythonHelper.cpp b/src/libcalamares/PythonHelper.cpp index 5a3e2d648..d6e61b3aa 100644 --- a/src/libcalamares/PythonHelper.cpp +++ b/src/libcalamares/PythonHelper.cpp @@ -437,14 +437,24 @@ GlobalStoragePythonWrapper::keys() const int GlobalStoragePythonWrapper::remove( const std::string& key ) { - return m_gs->remove( QString::fromStdString( key ) ); + const QString gsKey( QString::fromStdString( key ) ); + if ( !m_gs->contains( gsKey ) ) + { + cWarning() << "Unknown GS key" << key.c_str(); + } + return m_gs->remove( gsKey ); } bp::object GlobalStoragePythonWrapper::value( const std::string& key ) const { - return CalamaresPython::variantToPyObject( m_gs->value( QString::fromStdString( key ) ) ); + const QString gsKey( QString::fromStdString( key ) ); + if ( !m_gs->contains( gsKey ) ) + { + cWarning() << "Unknown GS key" << key.c_str(); + } + return CalamaresPython::variantToPyObject( m_gs->value( gsKey ) ); } } // namespace CalamaresPython