Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
ua-parser==0.10.0
PyYAML==5.4; python_version != '3.4'
PyYAML==5.4; python_version == '3.4' # the last version support py34
ua-parser==1.0.0
PyYAML==5.4
14 changes: 6 additions & 8 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,20 @@
zip_safe=False,
include_package_data=True,
package_data={'': ['README.rst']},
install_requires=['ua-parser>=0.10.0'],
install_requires=['ua-parser>=1.0.0'],
python_requires='>=3.9',
classifiers=[
'Development Status :: 5 - Production/Stable',
'Environment :: Web Environment',
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
'Topic :: Internet :: WWW/HTTP',
'Topic :: Software Development :: Libraries :: Python Modules',
]
Expand Down
10 changes: 5 additions & 5 deletions user_agents/parsers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from collections import namedtuple

from ua_parser import user_agent_parser
from ua_parser import parser
from .compat import string_types


Expand Down Expand Up @@ -140,11 +140,11 @@ def parse_device(family, brand, model):
class UserAgent(object):

def __init__(self, user_agent_string):
ua_dict = user_agent_parser.Parse(user_agent_string)
ua = parser.parse(user_agent_string).with_defaults()
self.ua_string = user_agent_string
self.os = parse_operating_system(**ua_dict['os'])
self.browser = parse_browser(**ua_dict['user_agent'])
self.device = parse_device(**ua_dict['device'])
self.os = parse_operating_system(ua.os.family, ua.os.major, ua.os.minor, ua.os.patch)
self.browser = parse_browser(ua.user_agent.family, ua.user_agent.major, ua.user_agent.minor, ua.user_agent.patch)
self.device = parse_device(ua.device.family, ua.device.brand, ua.device.model)

def __str__(self):
return "{device} / {os} / {browser}".format(
Expand Down