<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def prepare_renderable(request, test_case_result, is_admin):
 """Return a completed Renderable."""

    test_case = test_case_result.test_case
    file_directory = request.registry.settings['file_directory']
    sha1 = test_case_result.diff.sha1 if test_case_result.diff else None
    kwargs = {'number': test_case.id, 'group': test_case.testable.name,
              'name': test_case.name, 'points': test_case.points,
              'status': test_case_result.status,
              'extra': test_case_result.extra}

    if test_case.output_type == 'image':
        url = request.route_path('file_item', filename='_', _query={'raw': 1},
                                 sha1sum=sha1) if sha1 else None
        return ImageOutput(url=url, **kwargs)
    elif test_case.output_type == 'text':
        content = None
        if sha1:
            with open(File.file_path(file_directory, sha1)) as fp:
                content = fp.read()
        return TextOutput(content=content, **kwargs)
    elif not test_case_result.diff:  # Outputs match
        return DiffWithMetadata(diff=None, **kwargs)

    try:
        with open(File.file_path(file_directory, sha1)) as fp:
            diff = pickle.load(fp)
    except (AttributeError, EOFError):
        content = 'submit system mismatch -- requeue submission'
        content += traceback.format_exc(1)
        return TextOutput(content=content, **kwargs)
    except Exception:
        content = 'unexected error -- requeue submission\n'
        content += traceback.format_exc(1)
        return TextOutput(content=content, **kwargs)

    diff.hide_expected = not is_admin and test_case.hide_expected
    return DiffWithMetadata(diff=diff, **kwargs)