From a988eaa999422e20fe39fbdf27152cf4b94b18c2 Mon Sep 17 00:00:00 2001 From: "Rafael G. Martins" Date: Fri, 10 Dec 2010 01:54:20 -0200 Subject: added comments to the checksum module --- g_octave/checksum.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/g_octave/checksum.py b/g_octave/checksum.py index 13be7ad..3ff8406 100644 --- a/g_octave/checksum.py +++ b/g_octave/checksum.py @@ -19,20 +19,21 @@ __all__ = [ 'sha1_check_db', ] -from hashlib import sha1 +import hashlib import json import os from .config import Config -from .compat import py3k config = Config() def sha1_compute(filename): + '''Computes the SHA1 checksum of a file''' with open(filename, 'rb') as fp: - return sha1(fp.read()).hexdigest() + return hashlib.sha1(fp.read()).hexdigest() def sha1_check(db, p): + '''Checks if the SHA1 checksum of the package is OK.''' description = db[p] manifest = {} with open(os.path.join(config.db, 'manifest.json')) as fp: @@ -42,6 +43,7 @@ def sha1_check(db, p): return manifest[p] == description.sha1sum() def sha1_check_db(db): + '''Checks if the SHA1 checksums of the package database are OK.''' for cat in db.pkg_list: for pkg in db.pkg_list[cat]: p = pkg['name']+'-'+pkg['version'] -- cgit v1.2.3-65-gdbad