/** * Build the script output for a single property * * @param propHistory :: reference to a property history object * @returns std::string for this property */ const std::string ScriptBuilder::buildPropertyString(PropertyHistory_const_sptr propHistory) { std::string prop = ""; if (!propHistory->isDefault()) { if(propHistory->type() == "number") { prop = propHistory->name() + "=" + propHistory->value(); } else if(propHistory->type() == "boolean") { std::string value = (propHistory->value() == "1" ? "True" : "False"); prop = propHistory->name() + "=" + value; } else { std::string opener = "='"; if (propHistory->value().find('\\') != std::string::npos ) { opener= "=r'"; } prop = propHistory->name() + opener + propHistory->value() + "'"; } } return prop; }
/** * Build the script output for a single property * * @param propHistory :: reference to a property history object * @returns std::string for this property */ const std::string ScriptBuilder::buildPropertyString(PropertyHistory_const_sptr propHistory) { using Mantid::Kernel::Direction; // Create a vector of all non workspace property type names std::vector<std::string> nonWorkspaceTypes; nonWorkspaceTypes.push_back("number"); nonWorkspaceTypes.push_back("boolean"); nonWorkspaceTypes.push_back("string"); std::string prop = ""; // No need to specify value for default properties if (!propHistory->isDefault()) { // Do not give values to output properties other than workspace properties if (find(nonWorkspaceTypes.begin(), nonWorkspaceTypes.end(), propHistory->type()) != nonWorkspaceTypes.end() && propHistory->direction() == Direction::Output) { g_log.debug() << "Ignoring property " << propHistory->name() << " of type " << propHistory->type() << std::endl; // Handle numerical properties } else if (propHistory->type() == "number") { prop = propHistory->name() + "=" + propHistory->value(); // Handle boolean properties } else if (propHistory->type() == "boolean") { std::string value = (propHistory->value() == "1" ? "True" : "False"); prop = propHistory->name() + "=" + value; // Handle all other property types } else { std::string opener = "='"; if (propHistory->value().find('\\') != std::string::npos) { opener = "=r'"; } prop = propHistory->name() + opener + propHistory->value() + "'"; } } return prop; }