Added a little test script
[pymailstats.git] / mailclient.py
blobb05600f0dc94a5ffcdc62edf20bc7a0eefad3de7
1 #!/usr/bin/env python
3 class mailClient:
5 def __init__(self, mailerstring):
6 # The following part needs to being moved
7 # to another structure. However. For the beginning it
8 # should work like this ... Or not ;)
10 tmp = mailerstring.split()
11 # setting default value to ensure we got some client
12 # in case no of the following rules apply
13 self.OS = None
14 self.mailclient = mailerstring
15 self.version = None
16 self.buildstr = None
17 if tmp[0] == "Sylpheed" and tmp[0] != mailerstring:
18 if tmp[1] == "version":
19 self.mailclient = tmp[0]
20 self.version = tmp[2]
21 self.buildstr = None
22 else:
23 self.mailclient = tmp[0]
24 self.version = tmp[1]
25 self.buildstr = tmp[2]
26 if tmp[0].startswith("Claws"):
27 self.mailclient = "Claws Mail"
28 self.version = tmp[2]
29 if (tmp[0] == "Thunderbird" or
30 tmp[0] == "Mozilla-Thunderbird" or
31 tmp[0] == "IceDove"):
32 self.mailclient = "Thunderbird"
33 self.version = tmp[1]
34 self.buildstr = tmp[2]
35 if tmp[0].startswith( "Mozilla/5.0"):
36 self.mailclient = "Mozilla based"
37 self.version = None
38 self.buildstr = None
39 if (tmp[0].startswith("Mutt") or
40 tmp[0].startswith("SquirrelMail") or
41 tmp[0].startswith("KMail") or
42 tmp[0].startswith("KNode") or
43 tmp[0].startswith("Gnus") or
44 tmp[0].startswith("tin") or
45 tmp[0].startswith("slrn") or
46 tmp[0].startswith("Pan")):
47 if tmp[0].find("/") > -1:
48 self.mailclient, self.version = tmp[0].split("/")
49 if self.version.find("+") > -1:
50 self.version, self.buildstr = self.version.split("+")
51 # Mailclient with single Name and simple version string
52 # without buildinfo
53 if tmp[0] == "Balsa" or tmp[0] == "Evolution":
54 self.mailclient = tmp[0]
55 self.version = tmp[1]
56 # Mailclient with single Name, version stirng and build string
57 if tmp[0] == "Alpine":
58 self.mailclient = tmp[0]
59 self.version = tmp[1]
60 self.buildstr = tmp[2]
62 def __cmp__(self, other):
63 return 0
65 def getOS(self):
66 """Not yet implemented"""
67 return self.OS
69 # def getMailClient(self):
70 # return self.mailclient, return self.version
72 def getVersion(self):
73 return self.version
75 def getBuildString(self):
76 return self.buildstr
78 def getMailClient(self):
79 return self.mailclient, self.version, self.buildstr, self.OS