static int reldep_init(_ReldepObject *self, PyObject *args, PyObject *kwds) { PyObject *sack; int cmp_type = 0; const char *reldep_str = NULL; char *name, *evr = NULL; if (!PyArg_ParseTuple(args, "O!s", &sack_Type, &sack, &reldep_str)) return -1; HySack csack = sackFromPyObject(sack); if (csack == NULL) return -1; if (parse_reldep_str(reldep_str, &name, &evr, &cmp_type) == -1) { PyErr_Format(HyExc_Value, "Wrong reldep format: %s", reldep_str); return -1; } self->reldep = hy_reldep_create(csack, name, cmp_type, evr); solv_free(name); solv_free(evr); if (self->reldep == NULL) { PyErr_Format(HyExc_Value, "No such reldep: %s", name); return -1; } return 0; }
static int reldep_init(_ReldepObject *self, PyObject *args, PyObject *kwds) { PyObject *sack; const char *reldep_str = NULL; PyObject *tmp_py_str = NULL; PyObject *reldep_str_py = NULL; if (!PyArg_ParseTuple(args, "O!O", &sack_Type, &sack, &reldep_str_py)) return -1; DnfSack *csack = sackFromPyObject(sack); if (csack == NULL) return -1; reldep_str = pycomp_get_string(reldep_str_py, &tmp_py_str); if (reldep_str == NULL) return -1; self->reldep = reldep_from_str (csack, reldep_str); if (self->reldep == NULL) { PyErr_Format(HyExc_Value, "Wrong reldep format: %s", reldep_str); Py_XDECREF(tmp_py_str); return -1; } Py_XDECREF(tmp_py_str); return 0; }
static PyObject * nevra_possibilities_real(_SubjectObject *self, PyObject *args, PyObject *kwds) { PyObject *sack = NULL; DnfSack *csack = NULL; int allow_globs = 0; int icase = 0; int flags = 0; PyObject *form = NULL; const char *kwlist[] = { "sack", "allow_globs", "icase", "form", NULL }; if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!|iiO", (char**) kwlist, &sack_Type, &sack, &allow_globs, &icase, &form)) return NULL; csack = sackFromPyObject(sack); if (csack == NULL) return NULL; HyForm *cforms = NULL; if (form != NULL) { cforms = fill_form(form); if (cforms == NULL) return NULL; } if (icase) flags |= HY_ICASE; if (allow_globs) flags |= HY_GLOB; HyPossibilities iter = hy_subject_nevra_possibilities_real(self->pattern, cforms, csack, flags); g_free(cforms); return possibilitiesToPyObject(iter, sack); }
int sack_converter(PyObject *o, DnfSack **sack_ptr) { DnfSack *sack = sackFromPyObject(o); if (sack == NULL) return 0; *sack_ptr = sack; return 1; }
PyObject * new_reldep(PyObject *sack, Id r_id) { HySack csack = sackFromPyObject(sack); if (csack == NULL) return NULL; _ReldepObject *self = reldep_new_core(&reldep_Type, sack); if (self == NULL) return NULL; self->reldep = reldep_create(sack_pool(csack), r_id); return (PyObject*)self; }
PyObject * new_reldep(PyObject *sack, Id r_id) { DnfSack *csack = sackFromPyObject(sack); if (csack == NULL) return NULL; _ReldepObject *self = reldep_new_core(&reldep_Type, sack); if (self == NULL) return NULL; self->reldep = dnf_reldep_from_pool (dnf_sack_get_pool(csack), r_id); return (PyObject*)self; }
static PyObject * to_query(_NevraObject *self, PyObject *args, PyObject *kwds) { PyObject *sack; HySack csack; if (!PyArg_ParseTuple(args, "O!", &sack_Type, &sack)) { return NULL; } csack = sackFromPyObject(sack); HyQuery query = hy_nevra_to_query(self->nevra, csack); PyObject *q = queryToPyObject(query, sack); return q; }
static int goal_init(_GoalObject *self, PyObject *args, PyObject *kwds) { PyObject *sack; HifSack *csack; if (!PyArg_ParseTuple(args, "O!", &sack_Type, &sack)) return -1; csack = sackFromPyObject(sack); if (csack == NULL) return -1; self->sack = sack; Py_INCREF(self->sack); // sack has to kept around until we are self->goal = hy_goal_create(csack); return 0; }
static int selector_init(_SelectorObject *self, PyObject *args, PyObject *kwds) { PyObject *sack; DnfSack *csack; if (!PyArg_ParseTuple(args, "O!", &sack_Type, &sack)) return -1; csack = sackFromPyObject(sack); if (csack == NULL) return -1; self->sack = sack; Py_INCREF(self->sack); // sack has to kept around until we are self->sltr = hy_selector_create(csack); return 0; }
static int package_init(_PackageObject *self, PyObject *args, PyObject *kwds) { Id id; PyObject *sack; HySack csack; if (!PyArg_ParseTuple(args, "(O!i)", &sack_Type, &sack, &id)) return -1; csack = sackFromPyObject(sack); if (csack == NULL) return -1; self->sack = sack; Py_INCREF(self->sack); self->package = package_create(csack, id); return 0; }
static PyObject * to_query(_NevraObject *self, PyObject *args, PyObject *kwds) { PyObject *sack; DnfSack *csack; const char *kwlist[] = {"sack", "icase", NULL}; PyObject *icase = NULL; if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!|O!", (char**) kwlist, &sack_Type, &sack, &PyBool_Type, &icase)) { return NULL; } gboolean c_icase = icase!=NULL && PyObject_IsTrue(icase); csack = sackFromPyObject(sack); HyQuery query = hy_query_from_nevra(self->nevra, csack, c_icase); PyObject *q = queryToPyObject(query, sack, &query_Type); return q; }
static PyObject * reldep_possibilities_real(_SubjectObject *self, PyObject *args, PyObject *kwds) { PyObject *sack = NULL; DnfSack *csack = NULL; int icase = 0; int flags = 0; const char *kwlist[] = { "sack", "icase", NULL }; if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!|i", (char**) kwlist, &sack_Type, &sack, &icase)) return NULL; csack = sackFromPyObject(sack); if (csack == NULL) return NULL; if (icase) flags |= HY_ICASE; HyPossibilities iter = hy_subject_reldep_possibilities_real(self->pattern, csack, flags); return possibilitiesToPyObject(iter, sack); }
static PyObject * set(_SelectorObject *self, PyObject *args) { key_t keyname; int cmp_type; PyObject *match; if (!PyArg_ParseTuple(args, "iiO", &keyname, &cmp_type, &match)) return NULL; if (keyname == HY_PKG) { const DnfPackageSet *pset; if (queryObject_Check(match)) { HyQuery target = queryFromPyObject(match); pset = hy_query_run_set(target); } else if (PyList_Check(match)) { DnfSack *sack = sackFromPyObject(self->sack); assert(sack); pset = pyseq_to_packageset(match, sack); } else { (ret2e(DNF_ERROR_BAD_SELECTOR, "Invalid value type: Only List and Query supported")); return NULL; } if (ret2e(hy_selector_pkg_set(self->sltr, keyname, cmp_type, pset), "Invalid Selector spec." )) { return NULL; } } else { const char *cmatch; PyObject *tmp_py_str = NULL; cmatch = pycomp_get_string(match, &tmp_py_str); if (ret2e(hy_selector_set(self->sltr, keyname, cmp_type, cmatch), "Invalid Selector spec." )) return NULL; } Py_RETURN_NONE; }