<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def parse_zip(zipfilename: str, regex: Pattern, invert_match: bool, files_with_matches: bool, files_without_match: bool, grep_inner_file_name: bool, show_inner_file: bool) -> None: """ Implement a "grep within an OpenXML file" for a single OpenXML file, which is by definition a ``.zip`` file. Args: zipfilename: name of the OpenXML (zip) file regex: regular expression to match invert_match: find files that do NOT match, instead of ones that do? files_with_matches: show filenames of files with a match? files_without_match: show filenames of files with no match? grep_inner_file_name: search the names of "inner" files, rather than their contents? show_inner_file: show the names of the "inner" files, not just the "outer" (OpenXML) file? """

    assert not (files_without_match and files_with_matches)
    report_lines = (not files_without_match) and (not files_with_matches)
    report_hit_lines = report_lines and not invert_match
    report_miss_lines = report_lines and invert_match
    log.debug("Checking ZIP: " + zipfilename)
    found_in_zip = False
    try:
        with ZipFile(zipfilename, 'r') as zf:
            for contentsfilename in zf.namelist():
                log.debug("... checking file: " + contentsfilename)
                if grep_inner_file_name:
                    found_in_filename = bool(regex.search(contentsfilename))
                    found_in_zip = found_in_zip or found_in_filename
                    if files_with_matches and found_in_zip:
                        report_hit_filename(zipfilename, contentsfilename,
                                            show_inner_file)
                        return
                    if ((report_hit_lines and found_in_filename) or
                            (report_miss_lines and not found_in_filename)):
                        report_line(zipfilename, contentsfilename,
                                    contentsfilename, show_inner_file)
                else:
                    try:
                        with zf.open(contentsfilename, 'r') as file:
                            try:
                                for line in file.readlines():
                                    # log.debug("line: {!r}", line)
                                    found_in_line = bool(regex.search(line))
                                    found_in_zip = found_in_zip or found_in_line
                                    if files_with_matches and found_in_zip:
                                        report_hit_filename(zipfilename,
                                                            contentsfilename,
                                                            show_inner_file)
                                        return
                                    if ((report_hit_lines and found_in_line) or
                                            (report_miss_lines and
                                             not found_in_line)):
                                        report_line(zipfilename,
                                                    contentsfilename,
                                                    line, show_inner_file)
                            except EOFError:
                                pass
                    except RuntimeError as e:
                        log.warning(
                            "RuntimeError whilst processing {} [{}]: probably "
                            "encrypted contents; error was {!r}",
                            zipfilename, contentsfilename, e)
    except (zlib.error, BadZipFile) as e:
        log.debug("Invalid zip: {}; error was {!r}", zipfilename, e)
    if files_without_match and not found_in_zip:
        report_miss_filename(zipfilename)