Commit 941f596e authored by Julian Andres Klode's avatar Julian Andres Klode

pkgrecords: Use hashes instead of deprecated MD5Hash and friends

parent ec1c8675
......@@ -1357,16 +1357,30 @@ Records (Release files, Packages, Sources)
Return the field 'Filename' of the record. This is the path to the
package, relative to the base path of the archive.
.. attribute:: hashes
A :class:`apt_pkg.HashStringList` of all hashes.
.. versionadded:: 1.1
.. attribute:: md5_hash
Return the MD5 hashsum of the package This refers to the field
'MD5Sum' in the raw record.
.. deprecated:: 1.1
Use :attr:`hashes` instead.
.. attribute:: sha1_hash
Return the SHA1 hashsum of the package. This refers to the field 'SHA1'
in the raw record.
.. deprecated:: 1.1
Use :attr:`hashes` instead.
.. attribute:: sha256_hash
Return the SHA256 hashsum of the package. This refers to the field
......@@ -1374,6 +1388,10 @@ Records (Release files, Packages, Sources)
.. versionadded:: 0.7.9
.. deprecated:: 1.1
Use :attr:`hashes` instead.
.. attribute:: source_pkg
The name of the source package, if different from the name of the
......
......@@ -70,17 +70,43 @@ static PyObject *PkgRecordsGetFileName(PyObject *Self,void*) {
PkgRecordsStruct &Struct = GetStruct(Self,"FileName");
return (Struct.Last != 0) ? CppPyString(Struct.Last->FileName()) : 0;
}
static PyObject *PkgRecordsGetHashes(PyObject *Self,void*) {
APT_IGNORE_DEPRECATED_PUSH
PkgRecordsStruct &Struct = GetStruct(Self,"Hashes");
if (Struct.Last == 0)
return 0;
auto py = CppPyObject_NEW<HashStringList> (nullptr, &PyHashStringList_Type);
py->Object = Struct.Last->Hashes();
return py;
APT_IGNORE_DEPRECATED_POP
}
static PyObject *PkgRecordsGetMD5Hash(PyObject *Self,void*) {
APT_IGNORE_DEPRECATED_PUSH
PkgRecordsStruct &Struct = GetStruct(Self,"MD5Hash");
if (PyErr_WarnEx(PyExc_DeprecationWarning,
"MD5Hash is deprecated, use Hashes instead", 1) == -1)
return NULL;
return (Struct.Last != 0) ? CppPyString(Struct.Last->MD5Hash()) : 0;
APT_IGNORE_DEPRECATED_POP
}
static PyObject *PkgRecordsGetSHA1Hash(PyObject *Self,void*) {
APT_IGNORE_DEPRECATED_PUSH
PkgRecordsStruct &Struct = GetStruct(Self,"SHA1Hash");
if (PyErr_WarnEx(PyExc_DeprecationWarning,
"SHA1Hash is deprecated, use Hashes instead", 1) == -1)
return NULL;
return (Struct.Last != 0) ? CppPyString(Struct.Last->SHA1Hash()) : 0;
APT_IGNORE_DEPRECATED_POP
}
static PyObject *PkgRecordsGetSHA256Hash(PyObject *Self,void*) {
APT_IGNORE_DEPRECATED_PUSH
PkgRecordsStruct &Struct = GetStruct(Self,"SHA256Hash");
if (PyErr_WarnEx(PyExc_DeprecationWarning,
"SHA256Hash is deprecated, use Hashes instead", 1) == -1)
return NULL;
return (Struct.Last != 0) ? CppPyString(Struct.Last->SHA256Hash()) : 0;
APT_IGNORE_DEPRECATED_POP
}
static PyObject *PkgRecordsGetSourcePkg(PyObject *Self,void*) {
PkgRecordsStruct &Struct = GetStruct(Self,"SourcePkg");
......@@ -126,6 +152,8 @@ static PyGetSetDef PkgRecordsGetSet[] = {
{"long_desc",PkgRecordsGetLongDesc,0,
"The long description of the packages; i.e. all lines in the\n"
"'Description' field except for the first one."},
{"hashes",PkgRecordsGetHashes,0,
"The hashes of the packages, as a HashStringList"},
{"md5_hash",PkgRecordsGetMD5Hash,0,
"The MD5 hash value of the package, as stored in the 'MD5Sum' field."},
{"maintainer",PkgRecordsGetMaintainer,0,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment