-
Notifications
You must be signed in to change notification settings - Fork 149
/
backend.py
33 lines (28 loc) · 1.09 KB
/
backend.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
"""ElementTree independent from the available distribution"""
try:
from xml.etree.cElementTree import *
except ImportError:
try:
from cElementTree import *
except ImportError:
from elementtree.ElementTree import *
class aMSNBackendManager(object):
def __init__(self):
self.switchToBackend('nullbackend')
def setBackendForFunc(self, funcname, backendname):
try:
m = __import__(backendname, globals(), locals(), [], -1)
except ImportError:
m = __import__('defaultbackend', globals(), locals(), [], -1)
try:
f = getattr(m, funcname)
self.__setattr__(funcname, f)
except AttributeError:
self.__setattr__(funcname, self.__missingFunc)
def switchToBackend(self, backend):
self.setBackendForFunc('getPassword', backend)
self.setBackendForFunc('setPassword', backend)
self.setBackendForFunc('saveConfig', backend)
self.setBackendForFunc('loadConfig', backend)
def __missingFunc(*args):
print 'Function not implemented for this backend'