From 4e885d92a7a2b838f4a3896dce731eede2807620 Mon Sep 17 00:00:00 2001 From: Alexander Moiseenko Date: Fri, 4 Jan 2019 16:06:57 +0300 Subject: [PATCH 1/2] fixed tests to be compatible with new ua-parser --- setup.py | 2 +- user_agents/parsers.py | 15 ++++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/setup.py b/setup.py index f396edb..0b915e8 100644 --- a/setup.py +++ b/setup.py @@ -14,7 +14,7 @@ zip_safe=False, include_package_data=True, package_data={'': ['README.rst']}, - install_requires=['ua-parser>=0.4.1'], + install_requires=['ua-parser>=0.8.0'], classifiers=[ 'Development Status :: 5 - Production/Stable', 'Environment :: Web Environment', diff --git a/user_agents/parsers.py b/user_agents/parsers.py index 5342c1a..5292c59 100644 --- a/user_agents/parsers.py +++ b/user_agents/parsers.py @@ -16,7 +16,6 @@ PC_OS_FAMILIES = ( 'Windows 95', 'Windows 98', - 'Windows ME', 'Solaris', ) @@ -51,8 +50,6 @@ 'iOS', 'Android', 'Windows Phone', - 'Windows Phone OS', - 'Windows RT', 'Windows CE', 'Windows Mobile', 'Firefox OS', @@ -172,7 +169,7 @@ def is_tablet(self): return True if (self.os.family == 'Android' and self._is_android_tablet()): return True - if self.os.family.startswith('Windows RT'): + if self.os.family == 'Windows' and self.os.version_string.startswith('RT'): return True if self.os.family == 'Firefox OS' and 'Mobile' not in self.browser.family: return True @@ -217,8 +214,11 @@ def is_touch_capable(self): return True if self.device.family in TOUCH_CAPABLE_DEVICE_FAMILIES: return True - if self.os.family.startswith('Windows 8') and 'Touch' in self.ua_string: - return True + if self.os.family == 'Windows': + if self.os.version_string.startswith('RT'): + return True + if self.os.version_string.startswith('8') and 'Touch' in self.ua_string: + return True if 'BlackBerry' in self.os.family and self._is_blackberry_touch_capable_device(): return True return False @@ -226,7 +226,8 @@ def is_touch_capable(self): @property def is_pc(self): # Returns True for "PC" devices (Windows, Mac and Linux) - if 'Windows NT' in self.ua_string or self.os.family in PC_OS_FAMILIES: + if 'Windows NT' in self.ua_string or self.os.family in PC_OS_FAMILIES or \ + self.os.family == 'Windows' and self.os.version_string == 'ME': return True # TODO: remove after https://github.com/tobie/ua-parser/issues/127 is closed if self.os.family == 'Mac OS X' and 'Silk' not in self.ua_string: From 74ff84af5c9a053273cfb04a5d2251319a415368 Mon Sep 17 00:00:00 2001 From: Alexander Moiseenko Date: Fri, 5 Apr 2019 23:19:16 +0300 Subject: [PATCH 2/2] enable xenial flag to work with py3.7 --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 1a6ea52..5897409 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,6 @@ sudo: false language: python +dist: xenial python: - "2.7" - "3.4"