From 7ff814790d4b4754349628b72fc4701f814bb0d5 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 5 Jul 2017 06:28:32 -0400 Subject: [PATCH] Python: get docstring from run() method --- src/libcalamares/PythonJob.cpp | 5 +++++ src/libcalamares/PythonJob.h | 1 + 2 files changed, 6 insertions(+) diff --git a/src/libcalamares/PythonJob.cpp b/src/libcalamares/PythonJob.cpp index 32e019eb0..a7922145a 100644 --- a/src/libcalamares/PythonJob.cpp +++ b/src/libcalamares/PythonJob.cpp @@ -228,6 +228,7 @@ PythonJob::PythonJob( const QString& scriptFile, : Job( parent ) , m_scriptFile( scriptFile ) , m_workingPath( workingPath ) + , m_description() , m_configurationMap( moduleConfiguration ) { } @@ -293,6 +294,10 @@ PythonJob::exec() scriptNamespace ); bp::object entryPoint = scriptNamespace[ "run" ]; + bp::extract< std::string > entryPoint_doc_attr(entryPoint.attr( "__doc__" ) ); + + if ( entryPoint_doc_attr.check() ) + m_description = QString::fromStdString( entryPoint_doc_attr() ); bp::object runResult = entryPoint(); diff --git a/src/libcalamares/PythonJob.h b/src/libcalamares/PythonJob.h index 9bc9ddb0b..d13705ed8 100644 --- a/src/libcalamares/PythonJob.h +++ b/src/libcalamares/PythonJob.h @@ -53,6 +53,7 @@ private: CalamaresPython::Helper* helper(); QString m_scriptFile; QString m_workingPath; + QString m_description; QVariantMap m_configurationMap; };