| 87 | } |
| 88 | |
| 89 | bool PythonPluginSearchPaths_Impl::addSearchPath(const openstudio::path& searchPath) { |
| 90 | std::vector<openstudio::path> existingSearchPaths = this->searchPaths(); |
| 91 | if (std::find(existingSearchPaths.begin(), existingSearchPaths.end(), searchPath) != existingSearchPaths.end()) { |
| 92 | LOG(Info, "Not adding search path '" << searchPath << "' to PythonPlugin:SearchPaths since it is already present"); |
| 93 | // Return true anyways, it's a success |
| 94 | return true; |
| 95 | } |
| 96 | |
| 97 | auto eg = getObject<ModelObject>().pushExtensibleGroup().cast<WorkspaceExtensibleGroup>(); |
| 98 | bool result = eg.setString(OS_PythonPlugin_SearchPathsExtensibleFields::SearchPath, searchPath.generic_string()); |
| 99 | if (!result) { |
| 100 | getObject<ModelObject>().eraseExtensibleGroup(eg.groupIndex()); |
| 101 | } |
| 102 | |
| 103 | return result; |
| 104 | } |
| 105 | |
| 106 | bool PythonPluginSearchPaths_Impl::setSearchPaths(const std::vector<openstudio::path>& searchPaths) { |
| 107 | bool result = true; |