From 16b7615619786a9428b2ac0e55f5d0f23bdd63d2 Mon Sep 17 00:00:00 2001 From: Sergey Polischouck Date: Tue, 15 Jan 2019 13:14:24 +0300 Subject: [PATCH 01/11] move uap-core to 0.6.4 --- uap-core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/uap-core b/uap-core index fc570f3..6cfb915 160000 --- a/uap-core +++ b/uap-core @@ -1 +1 @@ -Subproject commit fc570f378e41063bad3bdf0532967743efc75b4b +Subproject commit 6cfb915779a6b707b4f622cc1ebb70c15000bfb2 From c53f836045e3f3d534400b19b0c0a0ca6728ba04 Mon Sep 17 00:00:00 2001 From: Sergey Polischouck Date: Tue, 15 Jan 2019 13:26:00 +0300 Subject: [PATCH 02/11] temporary point to fork with needed regexes --- .gitmodules | 4 ++-- uap-core | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.gitmodules b/.gitmodules index 6d61431..1af85b5 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,4 +1,4 @@ [submodule "uap-core"] path = uap-core - url = https://github.com/ua-parser/uap-core.git - branch = master + url = https://github.com/admitad-github/uap-core + branch = feature/add-xiaomi-browsers diff --git a/uap-core b/uap-core index 6cfb915..4aac83f 160000 --- a/uap-core +++ b/uap-core @@ -1 +1 @@ -Subproject commit 6cfb915779a6b707b4f622cc1ebb70c15000bfb2 +Subproject commit 4aac83fc90373c63ee2a0c8c349deb7746b7ca48 From 684aebe439e2a987fd35756855aea668d0ed346d Mon Sep 17 00:00:00 2001 From: Sergey Polischouck Date: Wed, 13 Feb 2019 15:32:33 +0300 Subject: [PATCH 03/11] reference official updated uap-core repo --- .gitmodules | 4 ++-- uap-core | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.gitmodules b/.gitmodules index 1af85b5..fd375d2 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,4 +1,4 @@ [submodule "uap-core"] path = uap-core - url = https://github.com/admitad-github/uap-core - branch = feature/add-xiaomi-browsers + url = https://github.com/ua-parser/uap-core + branch = master diff --git a/uap-core b/uap-core index 4aac83f..bb1a20e 160000 --- a/uap-core +++ b/uap-core @@ -1 +1 @@ -Subproject commit 4aac83fc90373c63ee2a0c8c349deb7746b7ca48 +Subproject commit bb1a20ea89e58614711afe5582ca57f16736d89b From d998dbb555bc36cb705da9f9700e7cd9b6868bac Mon Sep 17 00:00:00 2001 From: Sergey Polischouck Date: Tue, 9 Apr 2019 11:29:32 +0300 Subject: [PATCH 04/11] update uap-core submodule to 0.6.7 --- uap-core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/uap-core b/uap-core index bb1a20e..71ec72c 160000 --- a/uap-core +++ b/uap-core @@ -1 +1 @@ -Subproject commit bb1a20ea89e58614711afe5582ca57f16736d89b +Subproject commit 71ec72cd37a940683cd40af3f7ab738ecbdcc45b From 75b7d33b7935cde84c5b9ca3f6afc63a71c778d2 Mon Sep 17 00:00:00 2001 From: Sergey Polischouck Date: Tue, 23 Apr 2019 12:50:54 +0300 Subject: [PATCH 05/11] fix expected behaviour to get None instead of empty string for ua version parsing --- ua_parser/user_agent_parser.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ua_parser/user_agent_parser.py b/ua_parser/user_agent_parser.py index 68824cf..1844822 100644 --- a/ua_parser/user_agent_parser.py +++ b/ua_parser/user_agent_parser.py @@ -61,15 +61,15 @@ def Parse(self, user_agent_string): if self.v1_replacement: v1 = self.v1_replacement elif match.lastindex and match.lastindex >= 2: - v1 = match.group(2) + v1 = match.group(2) if match.group(2) != '' else None if self.v2_replacement: v2 = self.v2_replacement elif match.lastindex and match.lastindex >= 3: - v2 = match.group(3) + v2 = match.group(3) if match.group(3) != '' else None if match.lastindex and match.lastindex >= 4: - v3 = match.group(4) + v3 = match.group(4) if match.group(4) != '' else None return family, v1, v2, v3 From 6e8fc931da65da5c93aff0f46dff6c3a8e0eca28 Mon Sep 17 00:00:00 2001 From: Sergey Polischouck Date: Tue, 23 Apr 2019 13:43:34 +0300 Subject: [PATCH 06/11] fix os parsing specification with replacing --- ua_parser/user_agent_parser.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/ua_parser/user_agent_parser.py b/ua_parser/user_agent_parser.py index 1844822..aca021f 100644 --- a/ua_parser/user_agent_parser.py +++ b/ua_parser/user_agent_parser.py @@ -125,17 +125,26 @@ def Parse(self, user_agent_string): os_v1 = match.group(2) if self.os_v2_replacement: - os_v2 = self.os_v2_replacement + if re.search(r'\$2', self.os_v2_replacement): + os_v2 = re.sub(r'\$2', match.group(2), self.os_v2_replacement) + else: + os_v2 = self.os_v2_replacement elif match.lastindex and match.lastindex >= 3: os_v2 = match.group(3) if self.os_v3_replacement: - os_v3 = self.os_v3_replacement + if re.search(r'\$3', self.os_v3_replacement): + os_v3 = re.sub(r'\$3', match.group(3), self.os_v3_replacement) + else: + os_v3 = self.os_v3_replacement elif match.lastindex and match.lastindex >= 4: os_v3 = match.group(4) if self.os_v4_replacement: - os_v4 = self.os_v4_replacement + if re.search(r'\$4', self.os_v4_replacement): + os_v4 = re.sub(r'\$4', match.group(4), self.os_v4_replacement) + else: + os_v4 = self.os_v4_replacement elif match.lastindex and match.lastindex >= 5: os_v4 = match.group(5) From 6b9848fcf9e3420d0bf862685a79bf478962a176 Mon Sep 17 00:00:00 2001 From: Sergey Polischouck Date: Tue, 23 Apr 2019 13:46:55 +0300 Subject: [PATCH 07/11] pin project dependencies --- .travis.yml | 2 +- requirements.txt | 1 + requirements_dev.txt | 1 + tox.ini | 2 +- 4 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 requirements.txt create mode 100644 requirements_dev.txt diff --git a/.travis.yml b/.travis.yml index 3ec68a6..415df86 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,7 +12,7 @@ env: - TOX_ENV=py36-flake8 install: - - pip install tox + - pip install -r requirements_dev.txt script: - tox -e $TOX_ENV diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..6c05a61 --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +pyyaml==5.1 diff --git a/requirements_dev.txt b/requirements_dev.txt new file mode 100644 index 0000000..5440913 --- /dev/null +++ b/requirements_dev.txt @@ -0,0 +1 @@ +tox=3.9.0 diff --git a/tox.ini b/tox.ini index cfce717..2cde9e3 100644 --- a/tox.ini +++ b/tox.ini @@ -3,7 +3,7 @@ envlist = py26, py27, py36, docs, py27-flake8, py36-flake8 [testenv] deps = - pyyaml + -rrequirements.txt commands = python setup.py develop python ua_parser/user_agent_parser_test.py From 21415179a9da65cb36d5881b63636063a3fc213f Mon Sep 17 00:00:00 2001 From: Sergey Polischouck Date: Tue, 23 Apr 2019 13:49:16 +0300 Subject: [PATCH 08/11] fix format in requirements --- requirements_dev.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements_dev.txt b/requirements_dev.txt index 5440913..eb111cc 100644 --- a/requirements_dev.txt +++ b/requirements_dev.txt @@ -1 +1 @@ -tox=3.9.0 +tox==3.9.0 From a9665f7bf3e7f4dd0d37681c4c0adcb74fea8fe8 Mon Sep 17 00:00:00 2001 From: Sergey Polischouck Date: Tue, 23 Apr 2019 13:55:11 +0300 Subject: [PATCH 09/11] speed up ci with job parallelization (add support python3.7 and drop python2.6) --- .travis.yml | 29 ++++++++++++++++------------- tox.ini | 2 +- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/.travis.yml b/.travis.yml index 415df86..47cc983 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,18 +1,21 @@ sudo: false language: python -python: - - "3.6" - -env: - - TOX_ENV=py26 - - TOX_ENV=py27 - - TOX_ENV=py36 - - TOX_ENV=docs - - TOX_ENV=py27-flake8 - - TOX_ENV=py36-flake8 - install: - pip install -r requirements_dev.txt -script: - - tox -e $TOX_ENV +matrix: + include: + - python: 2.7 + env: + - TOX_ENV=py27 + - TOX_ENV=py27-flake8 + - python: 3.6 + env: + - TOX_ENV=py36 + - TOX_ENV=py36-flake8 + - TOX_ENV=docs + - python: 3.7 + env: + - TOX_ENV=py37 + +script: tox -e $TOX_ENV diff --git a/tox.ini b/tox.ini index 2cde9e3..31d2feb 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py26, py27, py36, docs, py27-flake8, py36-flake8 +envlist = py27, py36, py37, docs, py27-flake8, py36-flake8 [testenv] deps = From 8b39b340f17c3be7452fdedb529c730136dd7899 Mon Sep 17 00:00:00 2001 From: Sergey Polischouck Date: Tue, 23 Apr 2019 13:59:58 +0300 Subject: [PATCH 10/11] =?UTF-8?q?remove=20python=203.7=20because=20travis?= =?UTF-8?q?=20can=E2=80=99t=20build=20it?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .travis.yml | 3 --- tox.ini | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 47cc983..5780377 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,8 +14,5 @@ matrix: - TOX_ENV=py36 - TOX_ENV=py36-flake8 - TOX_ENV=docs - - python: 3.7 - env: - - TOX_ENV=py37 script: tox -e $TOX_ENV diff --git a/tox.ini b/tox.ini index 31d2feb..479012c 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py27, py36, py37, docs, py27-flake8, py36-flake8 +envlist = py27, py36, docs, py27-flake8, py36-flake8 [testenv] deps = From 779d917a23e43faa734b8da6029443b8269ee3ce Mon Sep 17 00:00:00 2001 From: Sergey Polischouck Date: Tue, 23 Apr 2019 14:30:58 +0300 Subject: [PATCH 11/11] improve readability --- ua_parser/user_agent_parser.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ua_parser/user_agent_parser.py b/ua_parser/user_agent_parser.py index aca021f..05875f2 100644 --- a/ua_parser/user_agent_parser.py +++ b/ua_parser/user_agent_parser.py @@ -61,15 +61,15 @@ def Parse(self, user_agent_string): if self.v1_replacement: v1 = self.v1_replacement elif match.lastindex and match.lastindex >= 2: - v1 = match.group(2) if match.group(2) != '' else None + v1 = match.group(2) or None if self.v2_replacement: v2 = self.v2_replacement elif match.lastindex and match.lastindex >= 3: - v2 = match.group(3) if match.group(3) != '' else None + v2 = match.group(3) or None if match.lastindex and match.lastindex >= 4: - v3 = match.group(4) if match.group(4) != '' else None + v3 = match.group(4) or None return family, v1, v2, v3