| 432 | } |
| 433 | |
| 434 | PyObject* PyAlgorithm::paramValue(PyAlgorithm* self, PyObject* obj) { |
| 435 | if (!PyString_Check(obj)) { |
| 436 | PyErr_SetString(PyExc_TypeError, "expected string as argument"); |
| 437 | return NULL; |
| 438 | } |
| 439 | |
| 440 | string name = PyString_AS_STRING(obj); |
| 441 | |
| 442 | // check if parameter exists |
| 443 | if (self->algo->defaultParameters().find(name) == self->algo->defaultParameters().end()) { |
| 444 | ostringstream msg; |
| 445 | msg << "'" << name << "' is not a parameter of " << self->algo->name(); |
| 446 | PyErr_SetString(PyExc_ValueError, msg.str().c_str()); |
| 447 | return NULL; |
| 448 | } |
| 449 | |
| 450 | // determine the type of the parameter and return the appropriate Python object |
| 451 | PyObject* result = paramToPython( self->algo->parameter(name) ); |
| 452 | |
| 453 | if (result == NULL) { |
| 454 | // param not configured |
| 455 | Py_RETURN_NONE; |
| 456 | } |
| 457 | else { |
| 458 | return result; |
| 459 | } |
| 460 | } |
| 461 | |
| 462 | |
| 463 | PyObject* PyAlgorithm::getDoc(PyAlgorithm* self) { |
no test coverage detected