def make_string_packer(padding=" ", nullterminated=False):
    def pack_string(space, packer, width):
        try:
            w_s = packer.args_w[packer.args_index]
        except __HOLE__:
            raise space.error(space.w_ArgumentError, "too few arguments")
        string = space.str_w(space.convert_type(w_s, space.w_string, "to_str"))
        if nullterminated:
            packer.result += string
            packer.result.append("\0")
        else:
            assert width >= 0
            string = string[:width]
            packer.result += string
            packer.result.extend([padding] * (width - len(string)))
        packer.args_index += 1
    return pack_string
dataset/ETHPy150Open topazproject/topaz/topaz/utils/packing/stringpacking.py/make_string_packer