Bug fixes with FBF Fonbuch...
[vuplus_dvbapp-plugin] / fritzcall / src / __init__.py
1 # -*- coding: utf-8 -*-
2 from Components.config import config #@UnresolvedImport
3 import gettext
4 from Tools.Directories import resolveFilename, SCOPE_PLUGINS, SCOPE_SKIN_IMAGE #@UnresolvedImport
5 try:
6         _ = gettext.translation('FritzCall', resolveFilename(SCOPE_PLUGINS, "Extensions/FritzCall/locale"), [config.osd.language.getText()]).gettext
7 except IOError:
8         pass
9
10 from time import localtime
11 def debug(message):
12         ltim = localtime()
13         headerstr = "%04d%02d%02d %02d:%02d " %(ltim[0],ltim[1],ltim[2],ltim[3],ltim[4])
14         message = headerstr + message
15         if config.plugins.FritzCall.debug.value:
16                 deb = open("/tmp/FritzDebug.log", "aw")
17                 deb.write(message + "\n")
18                 deb.close()
19
20 import re
21 def normalizePhoneNumber(intNo):
22         
23         found = re.match('^\+' + config.plugins.FritzCall.country.value.replace('00','') + '(.*)', intNo)
24         if found:
25                 intNo = '0' + found.group(1)
26         found = re.match('^\+(.*)', intNo)
27         if found:
28                 intNo = '00' + found.group(1)
29         intNo = intNo.replace('(', '').replace(')', '').replace(' ', '').replace('/', '').replace('-', '')
30         found = re.match('^49(.*)', intNo) # this is most probably an error
31         if found:
32                 intNo = '0' + found.group(1)
33         found = re.match('.*?([0-9]+)', intNo)
34         if found:
35                 return found.group(1)
36         else:
37                 return '0'