<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">from __future__ import annotations


class UserAgent:
    """Represents a parsed user agent header value.

    The default implementation does no parsing, only the :attr:`string`
    attribute is set. A subclass may parse the string to set the
    common attributes or expose other information. Set
    :attr:`werkzeug.wrappers.Request.user_agent_class` to use a
    subclass.

    :param string: The header value to parse.

    .. versionadded:: 2.0
        This replaces the previous ``useragents`` module, but does not
        provide a built-in parser.
    """

    platform: str | None = None
    """The OS name, if it could be parsed from the string."""

    browser: str | None = None
    """The browser name, if it could be parsed from the string."""

    version: str | None = None
    """The browser version, if it could be parsed from the string."""

    language: str | None = None
    """The browser language, if it could be parsed from the string."""

    def __init__(self, string: str) -&gt; None:
        self.string: str = string
        """The original header value."""

    def __repr__(self) -&gt; str:
        return f"&lt;{type(self).__name__} {self.browser}/{self.version}&gt;"

    def __str__(self) -&gt; str:
        return self.string

    def __bool__(self) -&gt; bool:
        return bool(self.browser)

    def to_header(self) -&gt; str:
        """Convert to a header value."""
        return self.string
</pre></body></html>