Thanks to visit codestin.com
Credit goes to github.com

Skip to content

update uap-core submodule #70

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Jul 31, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[submodule "uap-core"]
path = uap-core
url = https://github.com/ua-parser/uap-core.git
url = https://github.com/ua-parser/uap-core
branch = master
28 changes: 14 additions & 14 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
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 tox
- pip install -r requirements_dev.txt

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

script:
- tox -e $TOX_ENV
script: tox -e $TOX_ENV
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pyyaml==5.1
1 change: 1 addition & 0 deletions requirements_dev.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tox==3.9.0
4 changes: 2 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[tox]
envlist = py26, py27, py36, docs, py27-flake8, py36-flake8
envlist = 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
Expand Down
21 changes: 15 additions & 6 deletions ua_parser/user_agent_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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) or None

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am curious, is there any impact of this or None? seems like it would just cause v1 = None instead of v1 = '' - is that the intent?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it was intended to match with the tests in uap-core, e.g. uap-core/tests/test_os.yaml, where some fields have None instead of empty string.


if self.v2_replacement:
v2 = self.v2_replacement
elif match.lastindex and match.lastindex >= 3:
v2 = match.group(3)
v2 = match.group(3) or None

if match.lastindex and match.lastindex >= 4:
v3 = match.group(4)
v3 = match.group(4) or None

return family, v1, v2, v3

Expand Down Expand Up @@ -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)

Expand Down