def check_installed_files(self):
mismatches = []<EOL>base = os.path.dirname(self.path)<EOL>record_path = self.get_distinfo_file('<STR_LIT>')<EOL>for path, hash_value, size in self.list_installed_files():<EOL><INDENT>if not os.path.isabs(path):<EOL><INDENT>path = os.path.join(base, path)<EOL><DEDENT>if path == record_path:<EOL><INDENT>continue<EOL><DEDENT>if not os.path.exists(path):<EOL><INDENT>mismatches.append((path, '<STR_LIT>', True, False))<EOL><DEDENT>elif os.path.isfile(path):<EOL><INDENT>actual_size = str(os.path.getsize(path))<EOL>if size and actual_size != size:<EOL><INDENT>mismatches.append((path, '<STR_LIT:size>', size, actual_size))<EOL><DEDENT>elif hash_value:<EOL><INDENT>if '<STR_LIT:=>' in hash_value:<EOL><INDENT>hasher = hash_value.split('<STR_LIT:=>', <NUM_LIT:1>)[<NUM_LIT:0>]<EOL><DEDENT>else:<EOL><INDENT>hasher = None<EOL><DEDENT>with open(path, '<STR_LIT:rb>') as f:<EOL><INDENT>actual_hash = self.get_hash(f.read(), hasher)<EOL>if actual_hash != hash_value:<EOL><INDENT>mismatches.append((path, '<STR_LIT>', hash_value, actual_hash))<EOL><DEDENT><DEDENT><DEDENT><DEDENT><DEDENT>return mismatches<EOL>
Checks that the hashes and sizes of the files in ``RECORD`` are
matched by the files themselves. Returns a (possibly empty) list of
mismatches. Each entry in the mismatch list will be a tuple consisting
of the path, 'exists', 'size' or 'hash' according to what didn't match
(existence is checked first, then size, then hash), the expected
value and the actual value.