예제 #1
0
/** Handler of the start notifications. Adds an algorithm call to the script.
 * @param alg :: Shared pointer to the starting algorithm.
 */
void RecordPythonScript::startingHandle(API::IAlgorithm_sptr alg)
{
  auto props= alg->getProperties();

  std::string algString;
  for(auto p = props.begin() ; p != props.end(); ++p)
  {
    std::string opener = "='"; 
    if ((**p).value().find('\\') != std::string::npos )
    {
      opener= "=r'";
    }

    std::string paramString = (**p).name() + opener + (**p).value() + "'";

    // Miss out parameters that are empty.
    if(paramString.length() != 0)
    {
      if(algString.length() != 0)
      {
        algString += ",";
      }
      algString += paramString;
    }
  }

  m_generatedScript +=  alg->name() + "(" + algString + ")\n";
}
예제 #2
0
void Load::findFilenameProperty(const API::IAlgorithm_sptr &loader) {
  // Use the first file property as the main Filename
  const auto &props = loader->getProperties();
  for (auto prop : props) {
    auto *fp = dynamic_cast<API::MultipleFileProperty *>(prop);
    auto *fp2 = dynamic_cast<API::FileProperty *>(prop);
    if (fp) {
      m_filenamePropName = fp->name();
      break;
    }
    if (fp2) {
      m_filenamePropName = fp2->name();
      break;
    }
  }
  if (m_filenamePropName.empty()) {
    setPropertyValue("LoaderName", "");
    setProperty("LoaderVersion", -1);
    throw std::runtime_error("Cannot find FileProperty on " + loader->name() +
                             " algorithm.");
  }
}