def get_file_info_from_lines(filename, file_lines):
    hostname = None
a_hash = hashlib.sha1()
for line in file_lines:
    if '! Last ' in line:
        line = ''
if '! NVRAM ' in line:
    line = ''
a_hash.update(line.encode('utf-8'))
match = HOSTNAME_RE.match(line)
if match:
    hostname = match.group(1)
Using regex to replace file data