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

Method sGetImportType

src/App/ApplicationPy.cpp:761–799  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

759}
760
761PyObject* ApplicationPy::sGetImportType(PyObject* /*self*/, PyObject* args)
762{
763 char* psKey = nullptr;
764
765 if (!PyArg_ParseTuple(args, "|s", &psKey)) {
766 return nullptr;
767 }
768
769 if (psKey) {
770 Py::List list;
771 std::vector<std::string> modules = GetApplication().getImportModules(psKey);
772 for (const auto& it : modules) {
773 list.append(Py::String(it));
774 }
775
776 return Py::new_reference_to(list);
777 }
778
779 Py::Dict dict;
780 std::vector<std::string> types = GetApplication().getImportTypes();
781 for (const auto& it : types) {
782 std::vector<std::string> modules = GetApplication().getImportModules(it.c_str());
783 if (modules.empty()) {
784 dict.setItem(it.c_str(), Py::None());
785 }
786 else if (modules.size() == 1) {
787 dict.setItem(it.c_str(), Py::String(modules.front()));
788 }
789 else {
790 Py::List list;
791 for (const auto& jt : modules) {
792 list.append(Py::String(jt));
793 }
794 dict.setItem(it.c_str(), list);
795 }
796 }
797
798 return Py::new_reference_to(dict);
799}
800
801PyObject* ApplicationPy::sAddExportType(PyObject* /*self*/, PyObject* args)
802{

Callers

nothing calls this directly

Calls 9

new_reference_toFunction · 0.85
getImportModulesMethod · 0.80
getImportTypesMethod · 0.80
StringClass · 0.70
appendMethod · 0.45
c_strMethod · 0.45
emptyMethod · 0.45
sizeMethod · 0.45
frontMethod · 0.45

Tested by

no test coverage detected