Package madrona :: Package common :: Package uaparser
[hide private]

Source Code for Package madrona.common.uaparser

 1  import regexes 
 2  import parser 
 3  import clientos 
 4   
5 -def int_or_zero(x):
6 try: 7 return int(x) 8 except: 9 return 0
10
11 -class browser_platform():
12 - def __init__(self,ua):
13 a = parser.UserAgent(ua) 14 b = clientos.client_os(ua) 15 self.family = a.family 16 self.v1 = int_or_zero(a.v1) 17 self.v2 = int_or_zero(a.v2) 18 self.v3 = int_or_zero(a.v3) 19 self.platform = b['platform'] 20 self.full_platform = b['full_platform']
21
22 - def __repr__(self):
23 return "%s %d.%d.%d on %s" % (self.family,self.v1,self.v2,self.v3,self.platform)
24