small fixes (this is still not in any productive use!)
[enigma2-plugins.git] / webinterface / src / WebComponents / Converter / NetworkInfo.py
1 from Components.Converter.Converter import Converter
2 from Components.Element import cached
3
4 class NetworkInfo(Converter, object):
5         NAME = 0
6         MAC = 1
7         DHCP = 2
8         IP = 3
9         GATEWAY = 4
10         NETMASK = 5
11         
12         
13         def __init__(self, type):
14                 Converter.__init__(self, type)
15                 self.type = {
16                                          "Name" : self.NAME,                             
17                                          "Mac" : self.MAC,
18                                          "Dhcp" : self.DHCP,
19                                          "Ip" : self.IP,
20                                          "Gateway" : self.GATEWAY,
21                                          "Netmask" : self.NETMASK,                                       
22                                          }[type]
23         
24         @cached
25         def getText(self):
26                 iface = self.source.interface
27                 
28                 if self.type is self.NAME:
29                         return iface.name               
30                 elif self.type is self.MAC:
31                         return iface.mac
32                 elif self.type is self.DHCP:
33                         return iface.dhcp
34                 elif self.type is self.IP:
35                         return iface.ip
36                 elif self.type is self.GATEWAY:
37                         return iface.gateway
38                 elif self.type is self.NETMASK:
39                         return iface.netmask
40                 else:
41                         return _("N/A")
42         
43         text = property(getText)
44