import apt_pkg, apt_inst
from apt import OpProgress
+from Hash import HashObject
+
apt_pkg.init()
TRACKED_FILES = ['release', 'sources', 'packages']
"""An error occurred while trying to find a hash."""
log.msg('An error occurred while looking up a hash for: %s' % path)
log.err(failure)
- d.callback((None, None))
+ d.callback(HashObject())
def _findHash(self, loadResult, path, d):
"""Really find the hash for a path.
function are pending.
"""
if not loadResult:
- d.callback((None, None))
+ d.callback(HashObject())
return loadResult
# First look for the path in the cache of index files
if path.startswith(release[:-7]):
for indexFile in self.indexrecords[release]:
if release[:-7] + indexFile == path:
- d.callback(self.indexrecords[release][indexFile]['SHA1'])
+ h = HashObject()
+ h.setFromIndexRecord(self.indexrecords[release][indexFile])
+ d.callback(h)
return loadResult
package = path.split('/')[-1].split('_')[0]
for verFile in version.FileList:
if self.records.Lookup(verFile):
if '/' + self.records.FileName == path:
- d.callback((self.records.SHA1Hash, size))
+ h = HashObject()
+ h.setFromPkgRecord(self.records, size)
+ d.callback(h)
return loadResult
except KeyError:
pass
if self.srcrecords.Lookup(package):
for f in self.srcrecords.Files:
if path == '/' + f[2]:
- d.callback((f[0], f[1]))
+ h = HashObject()
+ h.setFromSrcRecord(f)
+ d.callback(h)
return loadResult
- d.callback((None, None))
+ d.callback(HashObject())
return loadResult
class TestAptPackages(unittest.TestCase):