pakfire_package_set_uuid(self->package, uuid);
}
-static PyObject* Package_get_hexdigest(PackageObject* self, enum pakfire_digest_types type) {
- enum pakfire_digest_types digest = 0;
-
- const char* hexdigest = pakfire_package_get_hexdigest(self->package, &digest);
- if (!hexdigest)
- Py_RETURN_NONE;
-
- // Is this the requested type?
- if (digest != type)
+static PyObject* Package_get_digest(PackageObject* self) {
+ enum pakfire_digest_types type = PAKFIRE_DIGEST_UNDEFINED;
+ const unsigned char* digest = NULL;
+ size_t length = 0;
+
+ // Fetch the digest
+ digest = pakfire_package_get_digest(self->package, &type, &length);
+ if (!digest)
Py_RETURN_NONE;
- return PyUnicode_FromString(hexdigest);
-}
-
-static PyObject* Package_get_hexdigest_sha2_256(PackageObject* self) {
- return Package_get_hexdigest(self, PAKFIRE_DIGEST_SHA2_256);
-}
-
-static PyObject* Package_get_hexdigest_sha2_512(PackageObject* self) {
- return Package_get_hexdigest(self, PAKFIRE_DIGEST_SHA2_512);
-}
-
-static int Package_set_hexdigest(PackageObject* self,
- const enum pakfire_digest_types type, PyObject* value) {
- const char* hexdigest = PyUnicode_FromValue(value);
-
- return pakfire_package_set_hexdigest(self->package, type, hexdigest);
-}
-
-static int Package_set_hexdigest_sha2_256(PackageObject* self, PyObject* value) {
- return Package_set_hexdigest(self, PAKFIRE_DIGEST_SHA2_256, value);
-}
-
-static int Package_set_hexdigest_sha2_512(PackageObject* self, PyObject* value) {
- return Package_set_hexdigest(self, PAKFIRE_DIGEST_SHA2_512, value);
+ return Py_BuildValue("(sy#)", pakfire_digest_name(type), digest, length);
}
static PyObject* Package_get_summary(PackageObject* self) {
"dump",
(PyCFunction)Package_dump,
METH_VARARGS|METH_KEYWORDS,
- NULL
+ NULL,
},
{ NULL },
};
NULL
},
{
- "hexdigest_sha2_256",
- (getter)Package_get_hexdigest_sha2_256,
- (setter)Package_set_hexdigest_sha2_256,
+ "digest",
+ (getter)Package_get_digest,
+ NULL,
NULL,
- NULL
- },
- {
- "hexdigest_sha2_512",
- (getter)Package_get_hexdigest_sha2_512,
- (setter)Package_set_hexdigest_sha2_512,
NULL,
- NULL
},
{
"summary",