Skip to content

Commit 87936f2

Browse files
IMDaggerselwin
authored andcommitted
Fixed parser to be compatible with new ua-parser (selwin#90)
* fixed tests to be compatible with new ua-parser * enable xenial flag to work with py3.7
1 parent a005ce8 commit 87936f2

3 files changed

Lines changed: 10 additions & 8 deletions

File tree

‎.travis.yml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
sudo: false
22
language: python
3+
dist: xenial
34
python:
45
- "2.7"
56
- "3.4"

‎setup.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
zip_safe=False,
1515
include_package_data=True,
1616
package_data={'': ['README.rst']},
17-
install_requires=['ua-parser>=0.4.1'],
17+
install_requires=['ua-parser>=0.8.0'],
1818
classifiers=[
1919
'Development Status :: 5 - Production/Stable',
2020
'Environment :: Web Environment',

‎user_agents/parsers.py‎

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
PC_OS_FAMILIES = (
1717
'Windows 95',
1818
'Windows 98',
19-
'Windows ME',
2019
'Solaris',
2120
)
2221

@@ -51,8 +50,6 @@
5150
'iOS',
5251
'Android',
5352
'Windows Phone',
54-
'Windows Phone OS',
55-
'Windows RT',
5653
'Windows CE',
5754
'Windows Mobile',
5855
'Firefox OS',
@@ -172,7 +169,7 @@ def is_tablet(self):
172169
return True
173170
if (self.os.family == 'Android' and self._is_android_tablet()):
174171
return True
175-
if self.os.family.startswith('Windows RT'):
172+
if self.os.family == 'Windows' and self.os.version_string.startswith('RT'):
176173
return True
177174
if self.os.family == 'Firefox OS' and 'Mobile' not in self.browser.family:
178175
return True
@@ -217,16 +214,20 @@ def is_touch_capable(self):
217214
return True
218215
if self.device.family in TOUCH_CAPABLE_DEVICE_FAMILIES:
219216
return True
220-
if self.os.family.startswith('Windows 8') and 'Touch' in self.ua_string:
221-
return True
217+
if self.os.family == 'Windows':
218+
if self.os.version_string.startswith('RT'):
219+
return True
220+
if self.os.version_string.startswith('8') and 'Touch' in self.ua_string:
221+
return True
222222
if 'BlackBerry' in self.os.family and self._is_blackberry_touch_capable_device():
223223
return True
224224
return False
225225

226226
@property
227227
def is_pc(self):
228228
# Returns True for "PC" devices (Windows, Mac and Linux)
229-
if 'Windows NT' in self.ua_string or self.os.family in PC_OS_FAMILIES:
229+
if 'Windows NT' in self.ua_string or self.os.family in PC_OS_FAMILIES or \
230+
self.os.family == 'Windows' and self.os.version_string == 'ME':
230231
return True
231232
# TODO: remove after https://github.com/tobie/ua-parser/issues/127 is closed
232233
if self.os.family == 'Mac OS X' and 'Silk' not in self.ua_string:

0 commit comments

Comments
 (0)