Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
This repository was archived by the owner on Dec 26, 2023. It is now read-only.

Commit 171b951

Browse filesBrowse files
committed
Make tests pass on Python 3.
1 parent 16472bd commit 171b951
Copy full SHA for 171b951

File tree

Expand file treeCollapse file tree

1 file changed

+15
-5
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+15
-5
lines changed

‎user_agents/parsers.py

Copy file name to clipboardExpand all lines: user_agents/parsers.py
+15-5Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
1+
import sys
12
from collections import namedtuple
23

34
from ua_parser import user_agent_parser
45

56

7+
PY2 = sys.version_info[0] == 2
8+
PY3 = sys.version_info[0] == 3
9+
10+
if PY3:
11+
string_types = str
12+
else:
13+
string_types = basestring
14+
15+
616
MOBILE_DEVICE_FAMILIES = (
717
'iPhone',
818
'iPod',
@@ -19,7 +29,7 @@
1929
TABLET_DEVICE_FAMILIES = (
2030
'iPad',
2131
'BlackBerry Playbook',
22-
'Blackberry Playbook', # Earlier versions of ua-parser returns "Blackberry" (caps)
32+
'Blackberry Playbook', # Earlier versions of ua-parser returns "Blackberry" instead of "BlackBerry"
2333
'Kindle',
2434
'Kindle Fire',
2535
)
@@ -41,13 +51,13 @@
4151

4252
def parse_version(major=None, minor=None, patch=None, patch_minor=None):
4353
# Returns version number tuple, attributes will be integer if they're numbers
44-
if major is not None and isinstance(major, basestring):
54+
if major is not None and isinstance(major, string_types):
4555
major = int(major) if major.isdigit() else major
46-
if minor is not None and isinstance(minor, basestring):
56+
if minor is not None and isinstance(minor, string_types):
4757
minor = int(minor) if minor.isdigit() else minor
48-
if patch is not None and isinstance(patch, basestring):
58+
if patch is not None and isinstance(patch, string_types):
4959
patch = int(patch) if patch.isdigit() else patch
50-
if patch_minor is not None and isinstance(patch_minor, basestring):
60+
if patch_minor is not None and isinstance(patch_minor, string_types):
5161
patch_minor = int(patch_minor) if patch_minor.isdigit() else patch_minor
5262
if patch_minor:
5363
return (major, minor, patch, patch_minor)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.