aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDetlev Casanova <detlev.casanova@gmail.com>2010-08-01 16:47:01 +0200
committerDetlev Casanova <detlev.casanova@gmail.com>2010-08-01 16:47:01 +0200
commit0e76a31c866aef80cf7c5f04e54bef3e3150a761 (patch)
tree61b6b134175dbd162e2d6a6d7c6bc80f3279322c /src/dataconnect.c
parentFix get_all_cpv_use, implement get_properties (diff)
downloadc-portage-0e76a31c866aef80cf7c5f04e54bef3e3150a761.tar.gz
c-portage-0e76a31c866aef80cf7c5f04e54bef3e3150a761.tar.bz2
c-portage-0e76a31c866aef80cf7c5f04e54bef3e3150a761.zip
Implement get_hard_masked and get_path,
Fix right method calls, Add a contains function to StringList, Make the test application look like emerge : ./run-test porthole Gives the best version to install with it's use flags.
Diffstat (limited to 'src/dataconnect.c')
-rw-r--r--src/dataconnect.c95
1 files changed, 46 insertions, 49 deletions
diff --git a/src/dataconnect.c b/src/dataconnect.c
index dc9d2ee..6c2764d 100644
--- a/src/dataconnect.c
+++ b/src/dataconnect.c
@@ -53,9 +53,32 @@ StringList* portageGetVersions(const char *pkg, int include_masked)
return ret;
}
-//int portageGetHardMasked(const char*)
-//{
-//}
+int portageGetHardMasked(const char* pkg, StringList** no_check, StringList** check)
+{
+ PyObject *obj = executeFunction("portage.api.data_connect", "get_hard_masked", "(z)", pkg);
+ if (!obj || !PySequence_Check(obj))
+ {
+ if (obj)
+ {
+ Py_DECREF(obj);
+ }
+ return 0;
+ }
+
+ PyObject *pynocheck = PySequence_GetItem(obj, 0);
+ assert(pynocheck);
+ PyObject *pycheck = PySequence_GetItem(obj, 1);
+ assert(pycheck);
+
+ *no_check = listToCList(pynocheck);
+ *check = listToCList(pycheck);
+
+ Py_DECREF(pynocheck);
+ Py_DECREF(pycheck);
+ Py_DECREF(obj);
+
+ return 1;
+}
StringList* portageGetInstalledFiles(const char *pkg)
{
@@ -81,16 +104,10 @@ char* portageBestVersion(StringList *pkgs)
{
assert(pkgs);
PyObject *pylist = cListToPyList(pkgs);
- PyObject *obj = executeFunction("portage.api.data_connect", "best_version", "(O)", pylist);
+ PyObject *obj = executeFunction("portage.api.data_connect", "best", "(O)", pylist);
Py_DECREF(pylist);
- if (!obj || !PyString_Check(obj))
- {
- if (obj)
- {
- Py_DECREF(obj);
- }
+ if (!obj)
return NULL;
- }
char *ret = pyStringToString(obj);
@@ -124,14 +141,8 @@ char* portageGetDepEbuild(const char *pkg)
{
assert(pkg);
PyObject *obj = executeFunction("portage.api.data_connect", "get_dep_ebuild", "(z)", pkg);
- if (!obj || !PyUnicode_Check(obj))
- {
- if (obj)
- {
- Py_DECREF(obj);
- }
+ if (!obj)
return NULL;
- }
char *ret = pyStringToString(obj);
@@ -166,14 +177,8 @@ char* portageGetMaskingReason(const char *pkg)
{
assert(pkg);
PyObject *obj = executeFunction("portage.api.data_connect", "get_masking_reason", "(z)", pkg);
- if (!obj || !PyUnicode_Check(obj))
- {
- if (obj)
- {
- Py_DECREF(obj);
- }
+ if (!obj)
return NULL;
- }
char *ret = pyStringToString(obj);
@@ -207,14 +212,8 @@ char* portageGetPackageSizeString(const char *pkg)
{
assert(pkg);
PyObject *obj = executeFunction("portage.api.data_connect", "get_size", "(z)", pkg);
- if (!obj || !PyString_Check(obj))
- {
- if (obj)
- {
- Py_DECREF(obj);
- }
+ if (!obj)
return NULL;
- }
char *ret = pyStringToString(obj);
@@ -262,14 +261,8 @@ char* portageGetOverlay(const char *pkg)
{
assert(pkg);
PyObject *obj = executeFunction("portage.api.data_connect", "get_overlay", "(z)", pkg);
- if (!obj || !PyUnicode_Check(obj))
- {
- if (obj)
- {
- Py_DECREF(obj);
- }
+ if (!obj)
return NULL;
- }
char *ret = pyStringToString(obj);
@@ -305,14 +298,8 @@ char* portageGetOverlayNameFromPkg(const char *pkg)
Py_INCREF(none);
PyObject *obj = executeFunction("portage.api.data_connect", "get_overlay_name", "(Oz)", none, pkg);
Py_DECREF(none);
- if (!obj || !PyUnicode_Check(obj))
- {
- if (obj)
- {
- Py_DECREF(obj);
- }
+ if (!obj)
return NULL;
- }
char *ret = pyStringToString(obj);
@@ -321,9 +308,19 @@ char* portageGetOverlayNameFromPkg(const char *pkg)
return ret;
}
-//char* portageGetPath(const char*, int)
-//{
-//}
+char* portageGetPath(const char* pkg, int vardb)
+{
+ assert(pkg);
+ PyObject *obj = executeFunction("portage.api.data_connect", "get_path", "(zI)", pkg, vardb);
+ if (!obj)
+ return NULL;
+
+ char *ret = pyStringToString(obj);
+
+ Py_DECREF(obj);
+
+ return ret;
+}
StringList* portageGetResolvedPkgs()