def format_string(code: str, pattern: str) -> str:
    """Format a single pattern line."""
    fmt = ' ' * 8 + "'{}': '{}'"
    code_len = len(code)
    pattern_len = len(pattern)
    if pattern_len > 63 - code_len:
        index = pattern_len // 2
        result = fmt.format(code, pattern[:index]) + '\n'
        result += ' ' * (code_len + 12) + "'{}',\n".format(pattern[index:])
    else:
        result = fmt.format(code, pattern) + ',\n'
    return result