def read_header(filename, return_idxs=False):
with open(filename, '<STR_LIT:rb>') as fh:<EOL><INDENT>header_dict = {}<EOL>header_idxs = {}<EOL>keyword, value, idx = read_next_header_keyword(fh)<EOL>try:<EOL><INDENT>assert keyword == b'<STR_LIT>'<EOL><DEDENT>except AssertionError:<EOL><INDENT>raise RuntimeError("<STR_LIT>")<EOL><DEDENT>while True:<EOL><INDENT>keyword, value, idx = read_next_header_keyword(fh)<EOL>if keyword == b'<STR_LIT>':<EOL><INDENT>break<EOL><DEDENT>else:<EOL><INDENT>header_dict[keyword] = value<EOL>header_idxs[keyword] = idx<EOL><DEDENT><DEDENT><DEDENT>if return_idxs:<EOL><INDENT>return header_idxs<EOL><DEDENT>else:<EOL><INDENT>return header_dict<EOL><DEDENT>
Read blimpy header and return a Python dictionary of key:value pairs

    Args:
        filename (str): name of file to open

    Optional args:
        return_idxs (bool): Default False. If true, returns the file offset indexes
                            for values

    returns