MCPcopy Create free account
hub / github.com/FreeCAD/FreeCAD / getLibrary

Method getLibrary

src/Mod/Material/App/ExternalManager.cpp:320–348  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

318}
319
320std::shared_ptr<Library> ExternalManager::getLibrary(const QString& name)
321{
322 // throw LibraryNotFound("Not yet implemented");
323 connect();
324
325 Base::PyGILStateLocker lock;
326 try {
327 if (_managerObject.hasAttr("getLibrary")) {
328 Py::Callable libraries(_managerObject.getAttr("getLibrary"));
329 Py::Tuple args(1);
330 args.setItem(0, Py::String(name.toStdString()));
331 Py::Object result(libraries.apply(args));
332
333 auto lib = libraryFromObject(result);
334 return std::make_shared<Library>(*lib);
335 }
336 else {
337 Base::Console().log("\tgetLibrary() not found\n");
338 throw ConnectionError();
339 }
340 }
341 catch (const InvalidLibrary&) {
342 throw LibraryNotFound();
343 }
344 catch (Py::Exception& e) {
345 Base::PyException e1; // extract the Python error text
346 throw LibraryNotFound(e1.what());
347 }
348}
349
350void ExternalManager::createLibrary(const QString& libraryName, const QByteArray& icon, bool readOnly)
351{

Callers 2

modelFromObjectMethod · 0.45
materialFromObjectMethod · 0.45

Calls 8

ConnectionErrorClass · 0.85
toStdStringMethod · 0.80
LibraryNotFoundClass · 0.70
connectFunction · 0.50
StringClass · 0.50
applyMethod · 0.45
logMethod · 0.45
whatMethod · 0.45

Tested by

no test coverage detected