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

Skip to content

Commit 326da3e

Browse files
authored
Merge pull request ua-parser#70 from admitad-github/feature/update-uap-core
update uap-core submodule
2 parents 457e19b + 779d917 commit 326da3e

File tree

7 files changed

+35
-24
lines changed

7 files changed

+35
-24
lines changed

.gitmodules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
[submodule "uap-core"]
22
path = uap-core
3-
url = https://github.com/ua-parser/uap-core.git
3+
url = https://github.com/ua-parser/uap-core
44
branch = master

.travis.yml

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
sudo: false
22
language: python
3-
python:
4-
- "3.6"
5-
6-
env:
7-
- TOX_ENV=py26
8-
- TOX_ENV=py27
9-
- TOX_ENV=py36
10-
- TOX_ENV=docs
11-
- TOX_ENV=py27-flake8
12-
- TOX_ENV=py36-flake8
13-
143
install:
15-
- pip install tox
4+
- pip install -r requirements_dev.txt
5+
6+
matrix:
7+
include:
8+
- python: 2.7
9+
env:
10+
- TOX_ENV=py27
11+
- TOX_ENV=py27-flake8
12+
- python: 3.6
13+
env:
14+
- TOX_ENV=py36
15+
- TOX_ENV=py36-flake8
16+
- TOX_ENV=docs
1617

17-
script:
18-
- tox -e $TOX_ENV
18+
script: tox -e $TOX_ENV

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pyyaml==5.1

requirements_dev.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
tox==3.9.0

tox.ini

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
[tox]
2-
envlist = py26, py27, py36, docs, py27-flake8, py36-flake8
2+
envlist = py27, py36, docs, py27-flake8, py36-flake8
33

44
[testenv]
55
deps =
6-
pyyaml
6+
-rrequirements.txt
77
commands =
88
python setup.py develop
99
python ua_parser/user_agent_parser_test.py

ua_parser/user_agent_parser.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,15 @@ def Parse(self, user_agent_string):
6161
if self.v1_replacement:
6262
v1 = self.v1_replacement
6363
elif match.lastindex and match.lastindex >= 2:
64-
v1 = match.group(2)
64+
v1 = match.group(2) or None
6565

6666
if self.v2_replacement:
6767
v2 = self.v2_replacement
6868
elif match.lastindex and match.lastindex >= 3:
69-
v2 = match.group(3)
69+
v2 = match.group(3) or None
7070

7171
if match.lastindex and match.lastindex >= 4:
72-
v3 = match.group(4)
72+
v3 = match.group(4) or None
7373

7474
return family, v1, v2, v3
7575

@@ -125,17 +125,26 @@ def Parse(self, user_agent_string):
125125
os_v1 = match.group(2)
126126

127127
if self.os_v2_replacement:
128-
os_v2 = self.os_v2_replacement
128+
if re.search(r'\$2', self.os_v2_replacement):
129+
os_v2 = re.sub(r'\$2', match.group(2), self.os_v2_replacement)
130+
else:
131+
os_v2 = self.os_v2_replacement
129132
elif match.lastindex and match.lastindex >= 3:
130133
os_v2 = match.group(3)
131134

132135
if self.os_v3_replacement:
133-
os_v3 = self.os_v3_replacement
136+
if re.search(r'\$3', self.os_v3_replacement):
137+
os_v3 = re.sub(r'\$3', match.group(3), self.os_v3_replacement)
138+
else:
139+
os_v3 = self.os_v3_replacement
134140
elif match.lastindex and match.lastindex >= 4:
135141
os_v3 = match.group(4)
136142

137143
if self.os_v4_replacement:
138-
os_v4 = self.os_v4_replacement
144+
if re.search(r'\$4', self.os_v4_replacement):
145+
os_v4 = re.sub(r'\$4', match.group(4), self.os_v4_replacement)
146+
else:
147+
os_v4 = self.os_v4_replacement
139148
elif match.lastindex and match.lastindex >= 5:
140149
os_v4 = match.group(5)
141150

0 commit comments

Comments
 (0)