def verify(self):
        "Compute the MD5 checksum for this log to see if the logfiles have been corrupted."
        # If there is no self.md5, no checksum exists for this log yet...
        if ( not hasattr(self,'md5') ):
            print 'WARNING: No MD5 checksum was found for log',self.name
            print 'WARNING: Log',self.name,'may be newly created, or it may be corrupt!'
            return
        
        # Otherwise, create the MD5 checksum from the log file and metadata file for verification
        import md5
        checksum = md5.new()
        mfn = open(self.mdf, 'r')
        for line in mfn.readlines():
            checksum.update(line)
        mfn.close()
        lfn = open(self.ldf, 'r')
        for line in lfn.readlines():
            checksum.update(line)
        lfn.close()
        cs = checksum.hexdigest()
        if ( self.debug == 'on' ):
            print 'DEBUG: The MD5 digest of the metadata and log files is',cs   
        if ( self.md5 == cs ):
            if ( self.debug == 'on' ):
                print 'DEBUG: The calculated MD5 checksum',cs,'matches the stored MD5 checksum',self.md5
        else:
            if ( self.debug == 'on' ):
                print 'DEBUG: The calculated MD5 checksum',cs,'does not match the stored MD5 checksum',self.md5                
            print 'ERROR: The MD5 checksum for log',self.name,'is inconsistent!'
            print 'ERROR: Log',self.name,'may be corrupt!'
Compute the MD5 checksum for this log to see if the logfiles have been corrupted.
recipes/Python/66452_Logpyl__basic_logfile_objects/recipe-66452.py