def parse_file(self, pythonpath, debug=False):

        text = "".join(read_batchfile(pythonpath, file_ending='.py'))

        def clean_block(text):
            text = RE_CLEANBLOCK.sub("", text)
            #text = re.sub(r"^\#.*?$|^\s*$", "", text, flags=re.MULTILINE)
            return "\n".join([line for line in text.split("\n") if line])

        def replace_insert(match):
            "Map replace entries"
            return "\#\n".join(self.parse_file(match.group(1)))

        text = RE_INSERT.sub(replace_insert, text)
        #text = re.sub(r"^\#INSERT (.*?)", replace_insert, text, flags=re.MULTILINE)
        blocks = RE_CODE_SPLIT.split(text)
        #blocks = re.split(r"(^\#CODE.*?$|^\#HEADER)$", text, flags=re.MULTILINE)
        headers = []
        codes = [] # list of tuples (code, info, objtuple)
        if blocks:
            if blocks[0]:
                # the first block is either empty or an unmarked code block
                code = clean_block(blocks.pop(0))
                if code:
                    codes.append((code, ""))
            iblock = 0
            for block in blocks[::2]:
                # loop over every second component; these are the #CODE/#HEADERs
                if block.startswith("#HEADER"):
                    headers.append(clean_block(blocks[iblock + 1]))
                elif block.startswith("#CODE"):
                    match = re.search(r"\(.*?\)", block)
                    info = match.group() if match else ""
                    objs = []
                    if debug:
                        # insert auto-delete lines into code
                        objs = block[match.end():].split(",")
                        objs = ["# added by Evennia's debug mode\n%s.delete()" % obj.strip() for obj in objs if obj]
                    # build the code block
                    code = "\n".join([clean_block(blocks[iblock + 1])] + objs)
                    if code:
                        codes.append((code, info))
                iblock += 2

        # join the headers together to one header
        headers = "\n".join(headers)
        if codes:
            # add the headers at the top of each non-empty block
            codes = ["%s\n%s\n%s" % ("#CODE %s: " % tup[1], headers, tup[0]) for tup in codes if tup[0]]
        else:
            codes = ["#CODE: \n" + headers]
        return codes
Apply ``pattern`` (contains no path elements) to the
dataset/ETHPy150Open evennia/evennia/evennia/utils/batchprocessors.py/BatchCodeProcessor.parse_file--crossover with--dataset/ETHPy150Open memsql/memsql-loader/memsql_loader/vendor/glob2/impl.py/Globber.resolve_pattern