def __init__(self, base_url, fname, fname_list): HashValidator.__init__(self, base_url) header_re = re.compile(r'(\w+):(.*)') hash_re = re.compile(r' ([0-9a-f]+)\s+([0-9]+)\s+(\S+)') current_header = '' with open(fname, 'r') as fp: for l in fp.readlines(): m = header_re.match(l) if m: # line contains an rfc822 Header, # remember it. current_header = m.group(1) continue m = hash_re.match(l) if m: # line contains a hash entry. # check filename, whether we are interested in it if m.group(3) in fname_list: self.insert_fname_hash(current_header, m.group(3), m.group(1))
def __init__(self, base_url, fname, fname_list): HashValidator.__init__(self, base_url) hash_re = re.compile(r'([0-9a-f]+)\s+(\S+)') with open(fname, 'r') as fp: for l in fp.readlines(): m = hash_re.match(l) if m: # line contains a hash entry. # check filename, whether we are interested in it if m.group(2) in fname_list: self.insert_fname_hash("SHA256", m.group(2), m.group(1))