static bool is_convertible(PyObject *ob, bool raise_exception) { import_numpy(); try { py2c(ob); return true; } catch (std::exception const &e) { if (raise_exception) { auto mess = std::string("Cannot convert to array/matrix/vector : the error was : \n") + e.what(); PyErr_SetString(PyExc_TypeError, mess.c_str()); } return false; } }
int main(int argc, char* argv[]) { if( argc != 4) { std::cerr << usage << std::endl; exit(-1); } Py2CConverter py2c(argv[1], argv[2]); std::string saveallstr(argv[3]); std::transform(saveallstr.begin(), saveallstr.end(), saveallstr.begin(), ::tolower); bool saveall = ((saveallstr == "true") ? true : false); py2c.convert(saveall); }