]>
jfr.im git - dlqueue.git/blob - venv/lib/python3.11/site-packages/werkzeug/user_agent.py
1 from __future__
import annotations
5 """Represents a parsed user agent header value.
7 The default implementation does no parsing, only the :attr:`string`
8 attribute is set. A subclass may parse the string to set the
9 common attributes or expose other information. Set
10 :attr:`werkzeug.wrappers.Request.user_agent_class` to use a
13 :param string: The header value to parse.
16 This replaces the previous ``useragents`` module, but does not
17 provide a built-in parser.
20 platform
: str |
None = None
21 """The OS name, if it could be parsed from the string."""
23 browser
: str |
None = None
24 """The browser name, if it could be parsed from the string."""
26 version
: str |
None = None
27 """The browser version, if it could be parsed from the string."""
29 language
: str |
None = None
30 """The browser language, if it could be parsed from the string."""
32 def __init__(self
, string
: str) -> None:
33 self
.string
: str = string
34 """The original header value."""
36 def __repr__(self
) -> str:
37 return f
"<{type(self).__name__} {self.browser}/{self.version}>"
39 def __str__(self
) -> str:
42 def __bool__(self
) -> bool:
43 return bool(self
.browser
)
45 def to_header(self
) -> str:
46 """Convert to a header value."""