-
Notifications
You must be signed in to change notification settings - Fork 2
/
osparser.py
105 lines (69 loc) · 1.8 KB
/
osparser.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
import sys
from agedata import AgeData
import re
from datetime import *
class OsParser(object):
""" Get Version Elements and return age results """
def __init__(self):
#'.*\(*(key1)|(key2).*\).*'
pass
def getParseOrder(self):
return sys.maxint
def doesMatch(self, ua):
return False
def getOs(self):
return ''
class OspWindows(OsParser):
def __init__(self):
self.matcher = re.compile('\(.*windows.*\)', re.IGNORECASE)
def getParseOrder(self):
return 1
def doesMatch(self, ua):
return bool(self.matcher.search(ua))
def getOs(self):
return 'windows'
class OspIOS(OsParser):
def __init__(self):
self.matcher = re.compile('\(.*(iphone)|(ipad).*\)', re.IGNORECASE)
def getParseOrder(self):
return 1
def doesMatch(self, ua):
return bool(self.matcher.search(ua))
def getOs(self):
return 'ios'
class OspOsx(OsParser):
def __init__(self):
self.matcher = re.compile('\(.*macintosh.*\)', re.IGNORECASE)
def getParseOrder(self):
return 2
def doesMatch(self, ua):
return bool(self.matcher.search(ua))
def getOs(self):
return 'osx'
class OspAndroid(OsParser):
def __init__(self):
self.matcher = re.compile('\(.*android.*\)', re.IGNORECASE)
def getParseOrder(self):
return 1
def doesMatch(self, ua):
return bool(self.matcher.search(ua))
def getOs(self):
return 'android'
class OspLinux(OsParser):
def __init__(self):
self.matcher = re.compile('\(.*linux.*\)', re.IGNORECASE)
def getParseOrder(self):
return 2
def doesMatch(self, ua):
return bool(self.matcher.search(ua))
def getOs(self):
return 'linux'
class OspBB(OsParser):
def __init__(self):
self.matcher = re.compile('\(.*rim.*\)|blackberry', re.IGNORECASE)
def getParseOrder(self):
return 2
def doesMatch(self, ua):
return bool(self.matcher.search(ua))
def getOs(self):
return 'bb'