def parse_idf(file_like):
tables_data = {}<EOL>head_comment = "<STR_LIT>"<EOL>record_data = None<EOL>make_new_record = True<EOL>copyright_list = get_multi_line_copyright_message().split("<STR_LIT:\n>")<EOL>for i, raw_line in enumerate(file_like):<EOL><INDENT>try:<EOL><INDENT>copyright_line = copyright_list[i]<EOL>if raw_line.strip() == copyright_line:<EOL><INDENT>continue<EOL><DEDENT><DEDENT>except IndexError:<EOL><INDENT>pass<EOL><DEDENT>split_line = raw_line.split("<STR_LIT:!>")<EOL>if len(split_line) == <NUM_LIT:1>:<EOL><INDENT>if len(split_line[<NUM_LIT:0>].strip()) == <NUM_LIT:0>:<EOL><INDENT>content, comment = None, None<EOL><DEDENT>else:<EOL><INDENT>content, comment = split_line[<NUM_LIT:0>].strip(), None<EOL><DEDENT><DEDENT>else:<EOL><INDENT>if len(split_line[<NUM_LIT:0>].strip()) == <NUM_LIT:0>:<EOL><INDENT>content, comment = None, "<STR_LIT:!>".join(split_line[<NUM_LIT:1>:])<EOL><DEDENT>else:<EOL><INDENT>content, comment = split_line[<NUM_LIT:0>].strip(), "<STR_LIT:!>".join(split_line[<NUM_LIT:1>:])<EOL><DEDENT><DEDENT>if (content, comment) == (None, None):<EOL><INDENT>continue<EOL><DEDENT>if not content:<EOL><INDENT>if record_data is None:  <EOL><INDENT>head_comment += comment.strip() + "<STR_LIT:\n>"<EOL><DEDENT>continue<EOL><DEDENT>record_end = content[-<NUM_LIT:1>] == "<STR_LIT:;>"<EOL>content = content[:-<NUM_LIT:1>]  <EOL>content_l = [text.strip() for text in content.split("<STR_LIT:U+002C>")]<EOL>if make_new_record:<EOL><INDENT>table_ref = table_name_to_ref(content_l[<NUM_LIT:0>].strip())<EOL>if table_ref.lower() in (<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>"<STR_LIT>"<EOL>):<EOL><INDENT>continue<EOL><DEDENT>if table_ref not in tables_data:<EOL><INDENT>tables_data[table_ref] = []<EOL><DEDENT>record_data = dict()<EOL>tables_data[table_ref].append(record_data)<EOL>content_l = content_l[<NUM_LIT:1>:]<EOL>make_new_record = False<EOL><DEDENT>for value_s in content_l:<EOL><INDENT>field_index = len(record_data)<EOL>record_data[field_index] = value_s<EOL><DEDENT>if record_end:<EOL><INDENT>make_new_record = True<EOL><DEDENT><DEDENT>tables_data["<STR_LIT>"] = head_comment<EOL>return tables_data<EOL>
Records are created from string.
They are not attached to idf yet.
in idf: header comment, chapter comments, records
in record: head comment, field comments, tail comment