def parse_requirements(file_):
modules = []<EOL>delim = ["<STR_LIT:<>", "<STR_LIT:>>", "<STR_LIT:=>", "<STR_LIT:!>", "<STR_LIT>"]<EOL>try:<EOL><INDENT>f = open_func(file_, "<STR_LIT:r>")<EOL><DEDENT>except OSError:<EOL><INDENT>logging.error("<STR_LIT>".format(file_))<EOL>raise<EOL><DEDENT>else:<EOL><INDENT>data = [x.strip() for x in f.readlines() if x != "<STR_LIT:\n>"]<EOL><DEDENT>finally:<EOL><INDENT>f.close()<EOL><DEDENT>data = [x for x in data if x[<NUM_LIT:0>].isalpha()]<EOL>for x in data:<EOL><INDENT>if not any([y in x for y in delim]):<EOL><INDENT>modules.append({"<STR_LIT:name>": x, "<STR_LIT:version>": None})<EOL><DEDENT>for y in x:<EOL><INDENT>if y in delim:<EOL><INDENT>module = x.split(y)<EOL>module_name = module[<NUM_LIT:0>]<EOL>module_version = module[-<NUM_LIT:1>].replace("<STR_LIT:=>", "<STR_LIT>")<EOL>module = {"<STR_LIT:name>": module_name, "<STR_LIT:version>": module_version}<EOL>if module not in modules:<EOL><INDENT>modules.append(module)<EOL><DEDENT>break<EOL><DEDENT><DEDENT><DEDENT>return modules<EOL>
Parse a requirements formatted file.

    Traverse a string until a delimiter is detected, then split at said
    delimiter, get module name by element index, create a dict consisting of
    module:version, and add dict to list of parsed modules.

    Args:
        file_: File to parse.

    Raises:
        OSerror: If there's any issues accessing the file.

    Returns:
        tuple: The contents of the file, excluding comments.