def badge(left_text: str, right_text: str, left_link: Optional[str] = None,<EOL>right_link: Optional[str] = None,<EOL>whole_link: Optional[str] = None, logo: Optional[str] = None,<EOL>left_color: str = '<STR_LIT>', right_color: str = '<STR_LIT>',<EOL>measurer: Optional[text_measurer.TextMeasurer] = None,<EOL>embed_logo: bool = False) -> str:
if measurer is None:<EOL><INDENT>measurer = (<EOL>precalculated_text_measurer.PrecalculatedTextMeasurer<EOL>.default())<EOL><DEDENT>if (left_link or right_link) and whole_link:<EOL><INDENT>raise ValueError(<EOL>'<STR_LIT>')<EOL><DEDENT>template = _JINJA2_ENVIRONMENT.get_template('<STR_LIT>')<EOL>if logo and embed_logo:<EOL><INDENT>logo = _embed_image(logo)<EOL><DEDENT>svg = template.render(<EOL>left_text=left_text,<EOL>right_text=right_text,<EOL>left_text_width=measurer.text_width(left_text) / <NUM_LIT>,<EOL>right_text_width=measurer.text_width(right_text) / <NUM_LIT>,<EOL>left_link=left_link,<EOL>right_link=right_link,<EOL>whole_link=whole_link,<EOL>logo=logo,<EOL>left_color=_NAME_TO_COLOR.get(left_color, left_color),<EOL>right_color=_NAME_TO_COLOR.get(right_color, right_color),<EOL>)<EOL>xml = minidom.parseString(svg)<EOL>_remove_blanks(xml)<EOL>xml.normalize()<EOL>return xml.documentElement.toxml()<EOL>
Creates a github-style badge as an SVG image.

    >>> badge(left_text='coverage', right_text='23%', right_color='red')
    '<svg...</svg>'
    >>> badge(left_text='build', right_text='green', right_color='green',
    ...       whole_link="http://www.example.com/")
    '<svg...</svg>'

    Args:
        left_text: The text that should appear on the left-hand-side of the
            badge e.g. "coverage".
        right_text: The text that should appear on the right-hand-side of the
            badge e.g. "23%".
        left_link: The URL that should be redirected to when the left-hand text
            is selected.
        right_link: The URL that should be redirected to when the right-hand
            text is selected.
        whole_link: The link that should be redirected to when the badge is
            selected. If set then left_link and right_right may not be set.
        logo: A url representing a logo that will be displayed inside the
            badge. Can be a data URL e.g. "data:image/svg+xml;utf8,<svg..."
        left_color: The color of the part of the badge containing the left-hand
            text. Can be an valid CSS color
            (see https://developer.mozilla.org/en-US/docs/Web/CSS/color) or a
            color name defined here:
            https://github.com/badges/shields/blob/master/lib/colorscheme.json
        right_color: The color of the part of the badge containing the
            right-hand text. Can be an valid CSS color
            (see https://developer.mozilla.org/en-US/docs/Web/CSS/color) or a
            color name defined here:
            https://github.com/badges/shields/blob/master/lib/colorscheme.json
        measurer: A text_measurer.TextMeasurer that can be used to measure the
            width of left_text and right_text.
        embed_logo: If True then embed the logo image directly in the badge.
            This can prevent an HTTP request and some browsers will not render
            external image referenced. When True, `logo` must be a HTTP/HTTPS
            URI or a filesystem path. Also, the `badge` call may raise an
            exception if the logo cannot be loaded, is not an image, etc.