diff --git a/pym/cl_utils.py b/pym/cl_utils.py index a9cb535..5df9da3 100644 --- a/pym/cl_utils.py +++ b/pym/cl_utils.py @@ -724,3 +724,18 @@ def removeProgramToEnvFile(nameProg, objVar): if not objVar.WriteList("cl_merges", force=True): return False return True + +def checkDigestFile(digestfile): + """Check digest by digestfile""" + reEntry = re.compile(r"# (\S+) HASH\n(\S+) (\S+)",re.S) + result = [] + for alg,hashdata,filename in \ + reEntry.findall(open(digestfile,'r').read()): + if hasattr(hashlib,alg.lower()): + hashobj = getattr(hashlib,alg.lower()) + filename = path.join(path.dirname(digestfile),filename) + if path.exists(filename): + digest = hashobj(open(filename,'r').read()) + result.append((alg, + digest.hexdigest().upper() == hashdata.upper())) + return result