@@ -57,6 +57,9 @@ and `os` attributes. For example:
57
57
user_agent.device # returns Device(family='iPhone')
58
58
user_agent.device.family # returns 'iPhone'
59
59
60
+ # Viewing a pretty string version
61
+ str (user_agent) # returns "iPhone / iOS 5.1 / Mobile Safari 5.1"
62
+
60
63
61
64
``user_agents `` also expose a few other more "sophisticated" attributes that are derived from one or
62
65
more basic attributes defined above. As for now, these attributes should correctly identify
@@ -85,6 +88,7 @@ For example:
85
88
user_agent.is_touch_capable # returns False
86
89
user_agent.is_pc # returns False
87
90
user_agent.is_bot # returns False
91
+ str (user_agent) # returns "BlackBerry 9700 / BlackBerry OS 5 / BlackBerry 9700"
88
92
89
93
# Now a Samsung Galaxy S3
90
94
ua_string = ' Mozilla/5.0 (Linux; U; Android 4.0.4; en-gb; GT-I9300 Build/IMM76D) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30'
@@ -94,6 +98,7 @@ For example:
94
98
user_agent.is_touch_capable # returns True
95
99
user_agent.is_pc # returns False
96
100
user_agent.is_bot # returns False
101
+ str (user_agent) # returns "GT-I9300 / Android 4.0.4 / Android 4.0.4"
97
102
98
103
# iPad's user agent string
99
104
ua_string = ' Mozilla/5.0(iPad; U; CPU iPhone OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B314 Safari/531.21.10'
@@ -103,6 +108,7 @@ For example:
103
108
user_agent.is_touch_capable # returns True
104
109
user_agent.is_pc # returns False
105
110
user_agent.is_bot # returns False
111
+ str (user_agent) # returns "iPad / iOS 3.2 / Mobile Safari 4.0.4"
106
112
107
113
# Kindle Fire's user agent string
108
114
ua_string = ' Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_3; en-us; Silk/1.1.0-80) AppleWebKit/533.16 (KHTML, like Gecko) Version/5.0 Safari/533.16 Silk-Accelerated=true'
@@ -112,6 +118,7 @@ For example:
112
118
user_agent.is_touch_capable # returns True
113
119
user_agent.is_pc # returns False
114
120
user_agent.is_bot # returns False
121
+ str (user_agent) # returns "Kindle Fire / Android / Amazon Silk 1.1.0-80"
115
122
116
123
# Touch capable Windows 8 device
117
124
ua_string = ' Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; Trident/6.0; Touch)'
@@ -121,6 +128,7 @@ For example:
121
128
user_agent.is_touch_capable # returns True
122
129
user_agent.is_pc # returns True
123
130
user_agent.is_bot # returns False
131
+ str (user_agent) # returns "PC / Windows 8 / IE 10"
124
132
125
133
126
134
Running Tests
@@ -132,6 +140,10 @@ Running Tests
132
140
Changelog
133
141
=========
134
142
143
+ Version 0.3.0
144
+ -------------
145
+ * Added __str__ method for convenience of pretty string
146
+
135
147
Version 0.2.0
136
148
-------------
137
149
* Fixed errors when running against newer versions if ua-parser
0 commit comments