aboutsummaryrefslogtreecommitdiff
path: root/venv/lib/python3.8/site-packages/werkzeug/user_agent.py
diff options
context:
space:
mode:
authorsotech117 <michael_foiani@brown.edu>2025-07-31 17:27:24 -0400
committersotech117 <michael_foiani@brown.edu>2025-07-31 17:27:24 -0400
commit5bf22fc7e3c392c8bd44315ca2d06d7dca7d084e (patch)
tree8dacb0f195df1c0788d36dd0064f6bbaa3143ede /venv/lib/python3.8/site-packages/werkzeug/user_agent.py
parentb832d364da8c2efe09e3f75828caf73c50d01ce3 (diff)
add code for analysis of data
Diffstat (limited to 'venv/lib/python3.8/site-packages/werkzeug/user_agent.py')
-rw-r--r--venv/lib/python3.8/site-packages/werkzeug/user_agent.py47
1 files changed, 47 insertions, 0 deletions
diff --git a/venv/lib/python3.8/site-packages/werkzeug/user_agent.py b/venv/lib/python3.8/site-packages/werkzeug/user_agent.py
new file mode 100644
index 0000000..17e5d3f
--- /dev/null
+++ b/venv/lib/python3.8/site-packages/werkzeug/user_agent.py
@@ -0,0 +1,47 @@
+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) -> None:
+ self.string: str = string
+ """The original header value."""
+
+ def __repr__(self) -> str:
+ return f"<{type(self).__name__} {self.browser}/{self.version}>"
+
+ def __str__(self) -> str:
+ return self.string
+
+ def __bool__(self) -> bool:
+ return bool(self.browser)
+
+ def to_header(self) -> str:
+ """Convert to a header value."""
+ return self.string