@classmethod
    def from_p8png_file(cls, instr, filename=None):
        # To install: python3 -m pip install pypng
        import png
        r = png.Reader(file=instr)

        (width, height, data, attrs) = r.read()
        picodata = [0] * width * height

        row_i = 0
        for row in data:
            for col_i in range(width):
                picodata[row_i * width + col_i] |= (
                    (row[col_i * attrs['planes'] + 2] & 3) << (0 * 2))
                picodata[row_i * width + col_i] |= (
                    (row[col_i * attrs['planes'] + 1] & 3) << (1 * 2))
                picodata[row_i * width + col_i] |= (
                    (row[col_i * attrs['planes'] + 0] & 3) << (2 * 2))
                picodata[row_i * width + col_i] |= (
                    (row[col_i * attrs['planes'] + 3] & 3) << (3 * 2))
            row_i += 1

        gfx = picodata[0x0:0x2000]
        p8map = picodata[0x2000:0x3000]
        gfx_props = picodata[0x3000:0x3100]
        song = picodata[0x3100:0x3200]
        sfx = picodata[0x3200:0x4300]
        code = picodata[0x4300:0x8000]
        version = picodata[0x8000]

        compressed_size = None

        if version == 0 or bytes(code[:4]) != b':c:\x00':
            # code is ASCII

            # (I assume this fails if uncompressed code completely
            # fills the code area, in which case code_length =
            # 0x8000-0x4300.)
            code_length = code.index(0)

            code = ''.join(chr(c) for c in code[:code_length]) + '\n'

        elif version == 1 or version == 5:
            # code is compressed
            code_length = (code[4] << 8) | code[5]
            assert bytes(code[6:8]) == b'\x00\x00'

            chars = list(b'#\n 0123456789abcdefghijklmnopqrstuvwxyz!#%(){}[]<>+=/*:;.,~_')
            out = [0] * code_length
            in_i = 8
            out_i = 0
            while out_i < code_length and in_i < len(code):
                if code[in_i] == 0x00:
                    in_i += 1
                    out[out_i] = code[in_i]
                    out_i += 1
                elif code[in_i] <= 0x3b:
                    out[out_i] = chars[code[in_i]]
                    out_i += 1
                else:
                    in_i += 1
                    offset = (code[in_i - 1] - 0x3c) * 16 + (code[in_i] & 0xf)
                    length = (code[in_i] >> 4) + 2
                    out[out_i:out_i + length] = out[out_i - offset:out_i - offset + length]
                    out_i += length
                in_i += 1

            code = ''.join(chr(c) for c in out) + '\n'
            compressed_size = in_i

        new_game = cls(filename=filename, compressed_size=compressed_size)
        new_game.version = version
        new_game.lua = Lua.from_lines(
            [code], version=version)
        new_game.gfx = Gfx.from_bytes(
            gfx, version=version)
        new_game.gff = Gff.from_bytes(
            gfx_props, version=version)
        new_game.map = Map.from_bytes(
            p8map, version=version, gfx=new_game.gfx)
        new_game.sfx = Sfx.from_bytes(
            sfx, version=version)
        new_game.music = Music.from_bytes(
            song, version=version)

        return new_game
Compiles the regex matches once the URL has been updated to include the full path from the parent class
dataset/ETHPy150Open dansanderson/picotool/pico8/game/game.py/Game.from_p8png_file--crossover with--dataset/ETHPy150Open jacek99/corepost/corepost/routing.py/UrlRouter.compileMatcherForFullUrl