Mantid
|
This class build a sttring which cana be executed as a python script. More...
#include <ScriptBuilder.h>
Public Member Functions | |
const std::string | build () |
build a python script from the history view More... | |
ScriptBuilder (const std::shared_ptr< HistoryView > &view, std::string versionSpecificity="old", bool appendTimestamp=false, std::vector< std::string > ignoreTheseAlgs={}, std::vector< std::vector< std::string > > ignoreTheseAlgProperties={}, bool appendExecCount=false) | |
virtual | ~ScriptBuilder ()=default |
Private Member Functions | |
const std::string | buildAlgorithmString (const AlgorithmHistory &algHistory) |
Build the script output for a single algorithm. More... | |
void | buildChildren (std::ostringstream &os, std::vector< HistoryItem >::const_iterator &iter, int depth=1) |
Iterate over each of the items children and output them to the script. More... | |
const std::string | buildCommentString (const AlgorithmHistory &algHistory) |
Build the script output for a single comment. More... | |
const std::string | buildPropertyString (const Mantid::Kernel::PropertyHistory &propHistory, const std::string &algName) |
Build the script output for a single property. More... | |
void | createStringForAlg (std::ostringstream &os, std::shared_ptr< const Mantid::API::AlgorithmHistory > &algHistory) |
void | writeHistoryToStream (std::ostringstream &os, std::vector< HistoryItem >::const_iterator &iter, int depth=1) |
Write out an algorithm to the script. More... | |
Private Attributes | |
std::vector< std::string > | m_algsToIgnore |
bool | m_execCount |
const std::vector< HistoryItem > | m_historyItems |
std::string | m_output |
std::vector< std::vector< std::string > > | m_propertiesToIgnore |
bool | m_timestampCommands |
std::string | m_versionSpecificity |
This class build a sttring which cana be executed as a python script.
Definition at line 31 of file ScriptBuilder.h.
Mantid::API::ScriptBuilder::ScriptBuilder | ( | const std::shared_ptr< HistoryView > & | view, |
std::string | versionSpecificity = "old" , |
||
bool | appendTimestamp = false , |
||
std::vector< std::string > | ignoreTheseAlgs = {} , |
||
std::vector< std::vector< std::string > > | ignoreTheseAlgProperties = {} , |
||
bool | appendExecCount = false |
||
) |
Definition at line 38 of file ScriptBuilder.cpp.
|
virtualdefault |
const std::string Mantid::API::ScriptBuilder::build | ( | ) |
build a python script from the history view
Build a python script for each algorithm included in the history view.
Definition at line 50 of file ScriptBuilder.cpp.
References m_historyItems, and writeHistoryToStream().
Referenced by AlgorithmHistoryWindow::copytoClipboard(), Mantid::Algorithms::GeneratePythonScript::exec(), and AlgorithmHistoryWindow::writeToScriptFile().
|
private |
Build the script output for a single algorithm.
algHistory | :: pointer to an algorithm history object |
Definition at line 167 of file ScriptBuilder.cpp.
References buildCommentString(), buildPropertyString(), Mantid::API::COMMENT_ALG, Mantid::Kernel::Logger::error(), Mantid::API::g_log, Mantid::API::AlgorithmHistory::getProperties(), Mantid::API::AlgorithmHistory::getPropertyValue(), Mantid::Kernel::SingletonHolder< T >::Instance(), m_versionSpecificity, Mantid::API::AlgorithmHistory::name(), Mantid::Kernel::Direction::Output, and Mantid::API::AlgorithmHistory::version().
Referenced by createStringForAlg().
|
private |
Iterate over each of the items children and output them to the script.
This moves the iterator forward over each of the child records and writes them to the stream.
os | :: output string stream to append algorithms to. |
iter | :: reference to the iterator pointing to the vector of history items |
depth | :: count of how far we've recursed into the history |
Definition at line 132 of file ScriptBuilder.cpp.
References m_historyItems, and writeHistoryToStream().
Referenced by writeHistoryToStream().
|
private |
Build the script output for a single comment.
algHistory | :: pointer to an algorithm history object |
Definition at line 147 of file ScriptBuilder.cpp.
References Mantid::API::COMMENT_ALG, Mantid::API::AlgorithmHistory::getProperties(), and Mantid::API::AlgorithmHistory::name().
Referenced by buildAlgorithmString().
|
private |
Build the script output for a single property.
propHistory | :: reference to a property history object |
algName | :: reference to the algorithm that the property is from's name |
Definition at line 256 of file ScriptBuilder.cpp.
References Mantid::Kernel::Logger::debug(), Mantid::Kernel::PropertyHistory::direction(), Mantid::API::g_log, Mantid::Kernel::PropertyHistory::isDefault(), m_algsToIgnore, m_propertiesToIgnore, Mantid::Kernel::PropertyHistory::name(), Mantid::Kernel::Direction::Output, Mantid::Kernel::PropertyHistory::type(), value, and Mantid::Kernel::PropertyHistory::value().
Referenced by buildAlgorithmString().
|
private |
Definition at line 102 of file ScriptBuilder.cpp.
References buildAlgorithmString(), m_execCount, and m_timestampCommands.
Referenced by writeHistoryToStream().
|
private |
Write out an algorithm to the script.
If the entry is unrolled this will recurse and output the children of that entry instead. If not, it will just output the algorithm to the stream.
os | :: output string stream to append algorithms to. |
iter | :: reference to the iterator pointing to the vector of history items |
depth | :: count of how far we've recursed into the history |
Definition at line 71 of file ScriptBuilder.cpp.
References buildChildren(), createStringForAlg(), m_algsToIgnore, m_historyItems, and m_timestampCommands.
Referenced by build(), and buildChildren().
|
private |
Definition at line 52 of file ScriptBuilder.h.
Referenced by buildPropertyString(), and writeHistoryToStream().
|
private |
Definition at line 54 of file ScriptBuilder.h.
Referenced by createStringForAlg().
|
private |
Definition at line 48 of file ScriptBuilder.h.
Referenced by build(), buildChildren(), and writeHistoryToStream().
|
private |
Definition at line 49 of file ScriptBuilder.h.
|
private |
Definition at line 53 of file ScriptBuilder.h.
Referenced by buildPropertyString().
|
private |
Definition at line 51 of file ScriptBuilder.h.
Referenced by createStringForAlg(), and writeHistoryToStream().
|
private |
Definition at line 50 of file ScriptBuilder.h.
Referenced by buildAlgorithmString().