1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 """Regexes."""
18
19 import parser
20
21
22 browser_slash_v123_names = (
23 'Jasmine|ANTGalio|Midori|Fresco|Lobo|Maxthon|Lynx|OmniWeb|Dillo|Camino|'
24 'Demeter|Fluid|Fennec|Shiira|Sunrise|Chrome|Flock|Netscape|Lunascape|'
25 'Epiphany|WebPilot|Vodafone|NetFront|Konqueror|SeaMonkey|Kazehakase|'
26 'Vienna|Iceape|Iceweasel|IceWeasel|Iron|K-Meleon|Sleipnir|Galeon|'
27 'GranParadiso|Opera Mini|iCab|NetNewsWire|Iron|Iris')
28
29 browser_slash_v12_names = (
30 'Bolt|Jasmine|Maxthon|Lynx|Arora|IBrowse|Dillo|Camino|Shiira|Fennec|'
31 'Phoenix|Chrome|Flock|Netscape|Lunascape|Epiphany|WebPilot|'
32 'Opera Mini|Opera|Vodafone|'
33 'NetFront|Konqueror|SeaMonkey|Kazehakase|Vienna|Iceape|Iceweasel|IceWeasel|'
34 'Iron|K-Meleon|Sleipnir|Galeon|GranParadiso|'
35 'iCab|NetNewsWire|Iron|Space Bison|Stainless|Orca')
36
37 _P = parser.UserAgentParser
38 USER_AGENT_PARSERS = (
39
40
41 _P(r'^(Opera)/(\d+)\.(\d+) \(Nintendo Wii', family_replacement='Wii'),
42
43 _P(r'(Namoroka|Shiretoko|Minefield)/(\d+)\.(\d+)\.(\d+(?:pre)?)',
44 'Firefox ($1)'),
45 _P(r'(Namoroka|Shiretoko|Minefield)/(\d+)\.(\d+)([ab]\d+[a-z]*)?',
46 'Firefox ($1)'),
47 _P(r'(SeaMonkey|Fennec|Camino)/(\d+)\.(\d+)([ab]?\d+[a-z]*)'),
48
49 _P(r'(Flock)/(\d+)\.(\d+)(b\d+?)'),
50
51
52 _P(r'(Fennec)/(\d+)\.(\d+)(pre)'),
53 _P(r'(Navigator)/(\d+)\.(\d+)\.(\d+)', 'Netscape'),
54 _P(r'(Navigator)/(\d+)\.(\d+)([ab]\d+)', 'Netscape'),
55 _P(r'(Netscape6)/(\d+)\.(\d+)\.(\d+)', 'Netscape'),
56 _P(r'(MyIBrow)/(\d+)\.(\d+)', 'My Internet Browser'),
57 _P(r'(Firefox).*Tablet browser (\d+)\.(\d+)\.(\d+)', 'MicroB'),
58
59
60 _P(r'(Opera)/9.80.*Version\/(\d+)\.(\d+)(?:\.(\d+))?'),
61
62 _P(r'(Firefox)/(\d+)\.(\d+)\.(\d+(?:pre)?) \(Swiftfox\)', 'Swiftfox'),
63 _P(r'(Firefox)/(\d+)\.(\d+)([ab]\d+[a-z]*)? \(Swiftfox\)', 'Swiftfox'),
64
65
66 _P(r'(konqueror)/(\d+)\.(\d+)\.(\d+)', 'Konqueror'),
67
68
69
70
71
72 _P(r'(%s)/(\d+)\.(\d+)\.(\d+)' % browser_slash_v123_names),
73
74 _P(r'(%s)/(\d+)\.(\d+)' % browser_slash_v12_names),
75
76 _P(r'(iRider|Crazy Browser|SkipStone|iCab|Lunascape|Sleipnir|Maemo Browser) (\d+)\.(\d+)\.(\d+)'),
77
78 _P(r'(iCab|Lunascape|Opera|Android) (\d+)\.(\d+)'),
79 _P(r'(IEMobile) (\d+)\.(\d+)', 'IE Mobile'),
80
81 _P(r'(Firefox)/(\d+)\.(\d+)\.(\d+)'),
82 _P(r'(Firefox)/(\d+)\.(\d+)(pre|[ab]\d+[a-z]*)?'),
83
84
85
86
87 _P(r'(Obigo|OBIGO)[^\d]*(\d+)(?:.(\d+))?', 'Obigo'),
88 _P(r'(MAXTHON|Maxthon) (\d+)\.(\d+)', family_replacement='Maxthon'),
89 _P(r'(Maxthon|MyIE2|Uzbl|Shiira)', v1_replacement='0'),
90 _P(r'(PLAYSTATION) (\d+)', family_replacement='PlayStation'),
91 _P(r'(PlayStation Portable)[^\d]+(\d+).(\d+)'),
92 _P(r'(BrowseX) \((\d+)\.(\d+)\.(\d+)'),
93 _P(r'(Opera)/(\d+)\.(\d+).*Opera Mobi', 'Opera Mobile'),
94 _P(r'(POLARIS)/(\d+)\.(\d+)', family_replacement='Polaris'),
95 _P(r'(BonEcho)/(\d+)\.(\d+)\.(\d+)', 'Bon Echo'),
96 _P(r'(iPhone) OS (\d+)_(\d+)(?:_(\d+))?'),
97 _P(r'(Avant)', v1_replacement='1'),
98 _P(r'(Nokia)[EN]?(\d+)'),
99 _P(r'(Black[bB]erry)(\d+)', family_replacement='Blackberry'),
100 _P(r'(OmniWeb)/v(\d+)\.(\d+)'),
101 _P(r'(Blazer)/(\d+)\.(\d+)', 'Palm Blazer'),
102 _P(r'(Pre)/(\d+)\.(\d+)', 'Palm Pre'),
103 _P(r'(Links) \((\d+)\.(\d+)'),
104 _P(r'(QtWeb) Internet Browser/(\d+)\.(\d+)'),
105 _P(r'(Version)/(\d+)\.(\d+)(?:\.(\d+))?.*Safari/',
106 family_replacement='Safari'),
107 _P(r'(OLPC)/Update(\d+)\.(\d+)'),
108 _P(r'(OLPC)/Update()\.(\d+)', v1_replacement='0'),
109 _P(r'(SamsungSGHi560)', family_replacement='Samsung SGHi560'),
110 _P(r'^(SonyEricssonK800i)', family_replacement='Sony Ericsson K800i'),
111 _P(r'(Teleca Q7)'),
112 _P(r'(MSIE) (\d+)\.(\d+)', family_replacement='IE'),
113 )
114