UPD: nrzuname results made more generic
authorMichael Schmidt <drmichael@users.schwerkraft.elitedvb.net>
Mon, 21 Sep 2009 07:23:04 +0000 (07:23 +0000)
committerMichael Schmidt <drmichael@users.schwerkraft.elitedvb.net>
Mon, 21 Sep 2009 07:23:04 +0000 (07:23 +0000)
FIX: reverselookup DE, SE, LU, US

fritzcall/src/nrzuname.py
fritzcall/src/plugin.py
fritzcall/src/reverselookup.xml

index ab60657..add59b9 100644 (file)
@@ -85,41 +85,28 @@ def normalizePhoneNumber(intNo):
 
 def out(number, caller):
        debug("[nrzuname] out: %s: %s" %(number, caller))
-       if not caller:
+       found = re.match("NA: ([^;]*);VN: ([^;]*);STR: ([^;]*);HNR: ([^;]*);PLZ: ([^;]*);ORT: ([^;]*)", caller)
+       if not found:
                return
-       name = vorname = strasse = hnr = plz = ort = ""
-       lines = caller.split(', ')
-       found = re.match("(.+?)\s+(.+)", lines[0])
-       if found:
-               name = found.group(1)
-               vorname = found.group(2)
-       else:
-               name = lines[0]
-
-       if len(lines) > 1:
-               if len(lines) > 2: # this means, we have street and city
-                       found = re.match("^(.+) ([-\d]+)$", lines[1], re.S)
-                       if found:
-                               strasse = found.group(1)
-                               hnr = found.group(2)
-                       else:
-                               found = re.match("^(\d+) (.+)$", lines[1], re.S)
-                               if found:
-                                       strasse = found.group(2)
-                                       hnr = found.group(1)
-                               else:
-                                       strasse = lines[1]
-                       for i in range(2, len(lines)):
-                               found = re.match("(\S+)\s+(.+)", lines[i], re.S)
-                               if found and re.search('\d', found.group(1)):
-                                       plz = found.group(1)
-                                       ort = found.group(2)
-                                       break
-               else: # only two lines, the second must be the city...
-                       ort = lines[1].strip()
-       print "NA: %s;VN: %s;STR: %s;HNR: %s;PLZ: %s;ORT: %s" %( name,vorname,strasse,hnr,plz,ort )
-
-def simpleout(number, caller):
+       ( name,vorname,strasse,hnr,plz,ort ) = (found.group(1),
+                                                                                       found.group(2),
+                                                                                       found.group(3),
+                                                                                       found.group(4),
+                                                                                       found.group(5),
+                                                                                       found.group(6)
+                                                                                       )
+       if vorname: name += ' ' + vorname
+       if strasse or hnr or plz or ort: name += ', '
+       if strasse: name += strasse
+       if hnr: name += ' ' + hnr
+       if (strasse or hnr) and (plz or ort): name += ', '
+       if plz and ort: name += plz + ' ' + ort
+       elif plz: name += plz
+       elif ort: name += ort
+
+       print(name)
+
+def simpleout(number, caller): #@UnusedVariable
        print caller
 
 try:
@@ -237,18 +224,26 @@ class ReverseLookupAndNotifier:
 
        def _gotPage(self, page):
                def cleanName(text):
-                       item = text.replace("&nbsp;"," ").replace("</b>","").replace(","," ").replace('\n',' ').replace('\t',' ')
-                       try:
-                               item = html2unicode(item).decode('iso-8859-1')
-                               # item = html2unicode(item)
-                               newitem = item.replace("  ", " ")
-                               while newitem != item:
-                                       item = newitem
-                                       newitem = item.replace("  ", " ")
-                               return newitem.strip()
+                       item = text.replace("%20"," ").replace("&nbsp;"," ").replace("</b>","").replace(","," ").replace('\n',' ').replace('\t',' ')
+
+                       item = html2unicode(item)
+                       try: # this works under Windows
+                               item = item.decode('iso-8859-1')
                        except:
-                               debug("[ReverseLookupAndNotifier] cleanName: " + traceback.format_exc())
-                               return item
+                               try: # this works under Enigma2
+                                       item = item.decode('utf-8')
+                               except:
+                                       try: # fall back
+                                               item = item.decode(self.charset)
+                                       except:
+                                               # debug("[ReverseLookupAndNotifier] cleanName: " + traceback.format_exc())
+                                               debug("[ReverseLookupAndNotifier] cleanName: encoding problem")
+
+                       newitem = item.replace("  ", " ")
+                       while newitem != item:
+                               item = newitem
+                               newitem = item.replace("  ", " ")
+                       return newitem.strip()
        
                debug("[ReverseLookupAndNotifier] _gotPage")
                found = re.match('.*<meta http-equiv="Content-Type" content="(?:application/xhtml\+xml|text/html); charset=([^"]+)" />',page, re.S)
@@ -278,8 +273,12 @@ class ReverseLookupAndNotifier:
                                                continue
                        
                        # look for <firstname> and <lastname> match, if not there look for <name>, if not there break
-                       lastname = ''
+                       name = ''
                        firstname = ''
+                       street = ''
+                       streetno = ''
+                       city = ''
+                       zipcode = ''
                        pat = self.getPattern(entry, "lastname")
                        if pat:
                                pat = ".*?" + pat
@@ -287,7 +286,7 @@ class ReverseLookupAndNotifier:
                                found = re.match(pat, page, re.S|re.M)
                                if found:
                                        debug("[ReverseLookupAndNotifier] _gotPage: found for '''%s''': '''%s'''" %( "lastname", found.group(1)))
-                                       lastname = cleanName(found.group(1))
+                                       name = cleanName(found.group(1))
 
                                        pat = self.getPattern(entry, "firstname")
                                        if pat:
@@ -296,12 +295,8 @@ class ReverseLookupAndNotifier:
                                                found = re.match(pat, page, re.S|re.M)
                                                if found:
                                                        debug("[ReverseLookupAndNotifier] _gotPage: found for '''%s''': '''%s'''" %( "firstname", found.group(1)))
-                                               firstname = cleanName(found.group(1))
+                                               firstname = cleanName(found.group(1)).strip()
 
-                                       if firstname:
-                                               name = lastname + ' ' + firstname
-                                       else:
-                                               name = lastname
                        else:
                                pat = ".*?" + self.getPattern(entry, "name")
                                debug("[ReverseLookupAndNotifier] _gotPage: look for '''%s''' with '''%s'''" %( "name", pat ))
@@ -309,52 +304,69 @@ class ReverseLookupAndNotifier:
                                if found:
                                        debug("[ReverseLookupAndNotifier] _gotPage: found for '''%s''': '''%s'''" %( "name", found.group(1)))
                                        item = cleanName(found.group(1))
-                                       debug("[ReverseLookupAndNotifier] _gotPage: name: " + item)
-                                       name = item
+                                       # debug("[ReverseLookupAndNotifier] _gotPage: name: " + item)
+                                       name = item.strip()
+                                       firstNameFirst = entry.getElementsByTagName('name')[0].getAttribute('swapFirstAndLastName')
+                                       # debug("[ReverseLookupAndNotifier] _gotPage: swapFirstAndLastName: " + firstNameFirst)
+                                       if firstNameFirst == 'true': # that means, the name is of the form "firstname lastname"
+                                               found = re.match('(.*?)\s+(.*)', name)
+                                               if found:
+                                                       firstname = found.group(1)
+                                                       name = found.group(2)
                                else:
                                        debug("[ReverseLookupAndNotifier] _gotPage: no name found, skipping")
                                        continue
 
-                       address = ""
-                       if name:
-                               pat = ".*?" + self.getPattern(entry, "city")
-                               debug("[ReverseLookupAndNotifier] _gotPage: look for '''%s''' with '''%s'''" %( "city", pat ))
-                               found = re.match(pat, page, re.S|re.M)
-                               if found:
-                                       debug("[ReverseLookupAndNotifier] _gotPage: found for '''%s''': '''%s'''" %( "city", found.group(1)))
-                                       item = cleanName(found.group(1))
-                                       debug("[ReverseLookupAndNotifier] _gotPage: city: " + item)
-                                       address = item.strip()
-
-                                       pat = ".*?" + self.getPattern(entry, "zipcode")
-                                       debug("[ReverseLookupAndNotifier] _gotPage: look for '''%s''' with '''%s'''" %( "zipcode", pat ))
-                                       found = re.match(pat, page, re.S|re.M)
-                                       if found and found.group(1):
-                                               debug("[ReverseLookupAndNotifier] _gotPage: found for '''%s''': '''%s'''" %( "zipcode", found.group(1)))
-                                               item = cleanName(found.group(1))
-                                               debug("[ReverseLookupAndNotifier] _gotPage: zipcode: " + item)
-                                               address = item.strip() + ' ' + address
-
-                                       pat = ".*?" + self.getPattern(entry, "street")
-                                       debug("[ReverseLookupAndNotifier] _gotPage: look for '''%s''' with '''%s'''" %( "street", pat ))
-                                       found = re.match(pat, page, re.S|re.M)
-                                       if found and found.group(1):
-                                               debug("[ReverseLookupAndNotifier] _gotPage: found for '''%s''': '''%s'''" %( "street", found.group(1)))
-                                               item = cleanName(found.group(1))
-                                               debug("[ReverseLookupAndNotifier] _gotPage: street: " + item)
-                                               address = item.strip() + ', ' + address
-
-                               if address:
-                                       debug("[ReverseLookupAndNotifier] _gotPage: Reverse lookup succeeded:\nName: %s\nAddress: %s" %(name, address))
-                                       self.caller = "%s, %s" %(name, address)
-                               else:
-                                       debug("[ReverseLookupAndNotifier] _gotPage: Reverse lookup succeeded:\nName: %s" %(name))
-                                       self.caller = name
+                       if not name:
+                               continue
 
-                               self.notifyAndReset()
-                               return True
-                       else:
+                       pat = ".*?" + self.getPattern(entry, "city")
+                       debug("[ReverseLookupAndNotifier] _gotPage: look for '''%s''' with '''%s'''" %( "city", pat ))
+                       found = re.match(pat, page, re.S|re.M)
+                       if found:
+                               debug("[ReverseLookupAndNotifier] _gotPage: found for '''%s''': '''%s'''" %( "city", found.group(1)))
+                               item = cleanName(found.group(1))
+                               debug("[ReverseLookupAndNotifier] _gotPage: city: " + item)
+                               city = item.strip()
+
+                       if not city:
                                continue
+
+                       pat = ".*?" + self.getPattern(entry, "zipcode")
+                       debug("[ReverseLookupAndNotifier] _gotPage: look for '''%s''' with '''%s'''" %( "zipcode", pat ))
+                       found = re.match(pat, page, re.S|re.M)
+                       if found and found.group(1):
+                               debug("[ReverseLookupAndNotifier] _gotPage: found for '''%s''': '''%s'''" %( "zipcode", found.group(1)))
+                               item = cleanName(found.group(1))
+                               debug("[ReverseLookupAndNotifier] _gotPage: zipcode: " + item)
+                               zipcode = item.strip()
+
+                       pat = ".*?" + self.getPattern(entry, "street")
+                       debug("[ReverseLookupAndNotifier] _gotPage: look for '''%s''' with '''%s'''" %( "street", pat ))
+                       found = re.match(pat, page, re.S|re.M)
+                       if found and found.group(1):
+                               debug("[ReverseLookupAndNotifier] _gotPage: found for '''%s''': '''%s'''" %( "street", found.group(1)))
+                               item = cleanName(found.group(1))
+                               debug("[ReverseLookupAndNotifier] _gotPage: street: " + item)
+                               street = item.strip()
+                               streetno = ''
+                               found = re.match("^(.+) ([-\d]+)$", street, re.S)
+                               if found:
+                                       street = found.group(1)
+                                       streetno= found.group(2)
+                               #===============================================================
+                               # else:
+                               #       found = re.match("^(\d+) (.+)$", street, re.S)
+                               #       if found:
+                               #               street = found.group(2)
+                               #               streetno = found.group(1)
+                               #===============================================================
+
+                       self.caller = "NA: %s;VN: %s;STR: %s;HNR: %s;PLZ: %s;ORT: %s" %( name,firstname,street,streetno,zipcode,city )
+                       debug("[ReverseLookupAndNotifier] _gotPage: Reverse lookup succeeded:\nName: %s" %(self.caller))
+
+                       self.notifyAndReset()
+                       return True
                else:
                        self._gotError("[ReverseLookupAndNotifier] _gotPage: Nothing found at %s" %self.currentWebsite.getAttribute("name"))
                        return False
@@ -403,10 +415,10 @@ if __name__ == '__main__':
        cwd = os.path.dirname(sys.argv[0])
        if (len(sys.argv) == 2):
                # nrzuname.py Nummer
-               ReverseLookupAndNotifier(sys.argv[1])
+               ReverseLookupAndNotifier(sys.argv[1], simpleout)
                reactor.run() #@UndefinedVariable
        elif (len(sys.argv) == 3):
                # nrzuname.py Nummer Charset
                setDebug(False)
-               ReverseLookupAndNotifier(sys.argv[1], simpleout, sys.argv[2])
+               ReverseLookupAndNotifier(sys.argv[1], out, sys.argv[2])
                reactor.run() #@UndefinedVariable
index b76a500..b2daf7e 100644 (file)
@@ -21,17 +21,17 @@ from Components.Label import Label
 from Components.Button import Button
 from Components.Pixmap import Pixmap
 from Components.config import config, ConfigSubsection, ConfigSelection, ConfigEnableDisable, getConfigListEntry, ConfigText, ConfigInteger
+from Components.ConfigList import ConfigListScreen
+from Components.Harddisk import harddiskmanager
 try:
        from Components.config import ConfigPassword
 except ImportError:
        ConfigPassword = ConfigText
-from Components.ConfigList import ConfigListScreen
-from Components.Harddisk import harddiskmanager
 
 from Plugins.Plugin import PluginDescriptor
 from Tools import Notifications
 from Tools.NumericalTextInput import NumericalTextInput
-from Tools.Directories import resolveFilename, SCOPE_PLUGINS, SCOPE_SKIN_IMAGE
+from Tools.Directories import resolveFilename, SCOPE_PLUGINS, SCOPE_SKIN_IMAGE, SCOPE_CONFIG, SCOPE_MEDIA
 from Tools.LoadPixmap import LoadPixmap
 
 from twisted.internet import reactor #@UnresolvedImport
@@ -101,11 +101,11 @@ config.plugins.FritzCall.prefix = ConfigText(default="", fixed_size=False)
 config.plugins.FritzCall.prefix.setUseableChars('0123456789')
 config.plugins.FritzCall.fullscreen = ConfigEnableDisable(default=False)
 
-mountedDevs= [("/etc/enigma2", _("Flash"))]
-if os.path.isdir("/media/cf"):
-       mountedDevs.append(("/media/cf", _("Compact Flash")))
-if os.path.isdir("/media/usb"):
-       mountedDevs.append(("/media/usb", _("USB Device")))
+mountedDevs= [(resolveFilename(SCOPE_CONFIG), _("Flash") + " (" + resolveFilename(SCOPE_CONFIG) + ")")]
+if os.path.isdir(resolveFilename(SCOPE_MEDIA, "cf")):
+       mountedDevs.append((resolveFilename(SCOPE_MEDIA, "cf"), _("Compact Flash") + " (" + resolveFilename(SCOPE_MEDIA, "cf") + ")"))
+if os.path.isdir(resolveFilename(SCOPE_MEDIA, "usb")):
+       mountedDevs.append((resolveFilename(SCOPE_MEDIA, "usb"), _("USB Device") + " (" + resolveFilename(SCOPE_MEDIA, "usb") + ")"))
 for p in harddiskmanager.getMountedPartitions(True):
        mp = p.mountpoint[:-1]
        if p.description:
@@ -179,6 +179,26 @@ def resolveNumberWithAvon(number, countrycode):
                        return '[' + avon[normNumber[:i]].strip() + ']'
        return ""
 
+def handleReverseLookupResult(name):
+       found = re.match("NA: ([^;]*);VN: ([^;]*);STR: ([^;]*);HNR: ([^;]*);PLZ: ([^;]*);ORT: ([^;]*)", name)
+       if found:
+               ( name,firstname,street,streetno,zipcode,city ) = (found.group(1),
+                                                                                               found.group(2),
+                                                                                               found.group(3),
+                                                                                               found.group(4),
+                                                                                               found.group(5),
+                                                                                               found.group(6)
+                                                                                               )
+               if firstname: name += ' ' + firstname
+               if street or streetno or zipcode or city: name += ', '
+               if street: name += street
+               if streetno:    name += ' ' + streetno
+               if (street or streetno) and (zipcode or city): name += ', '
+               if zipcode and city: name += zipcode + ' ' + city
+               elif zipcode: name += zipcode
+               elif city: name += city
+       return name
+
 from xml.dom.minidom import parse
 cbcInfos = {}
 def initCbC():
@@ -581,7 +601,7 @@ class FritzCallFBF:
                        self._callScreen.updateStatus(_("preparing"))
                parms = urlencode({'getpage':'../html/de/menus/menu2.html', 'var:lang':'de', 'var:pagename':'foncalls', 'var:menu':'fon', 'sid':self._md5Sid})
                url = "http://%s/cgi-bin/webcm?%s" % (config.plugins.FritzCall.hostname.value, parms)
-               getPage(url).addCallback(lambda x:self._getCalls1(callback)).addErrback(self._errorCalls)
+               getPage(url).addCallback(lambda x:self._getCalls1(callback)).addErrback(self._errorCalls) #@UnusedVariable
 
        def _getCalls1(self, callback):
                #
@@ -705,7 +725,7 @@ class FritzCallFBF:
                                        'Content-Length': str(len(parms))},
                        postdata=parms).addCallback(self._okDial).addErrback(self._errorDial)
 
-       def _okDial(self, html):
+       def _okDial(self, html): #@UnusedVariable
                debug("[FritzCallFBF] okDial")
 
        def _errorDial(self, error):
@@ -745,7 +765,7 @@ class FritzCallFBF:
                                        'Content-Length': str(len(parms))},
                        postdata=parms).addCallback(self._okChangeWLAN).addErrback(self._errorChangeWLAN)
 
-       def _okChangeWLAN(self, html):
+       def _okChangeWLAN(self, html): #@UnusedVariable
                debug("[FritzCallFBF] okDial")
 
        def _errorChangeWLAN(self, error):
@@ -805,7 +825,7 @@ class FritzCallFBF:
                                                'Content-Length': str(len(parms))},
                                postdata=parms).addCallback(self._okChangeMailbox).addErrback(self._errorChangeMailbox)
 
-       def _okChangeMailbox(self, html):
+       def _okChangeMailbox(self, html): #@UnusedVariable
                debug("[FritzCallFBF] _okChangeMailbox")
 
        def _errorChangeMailbox(self, error):
@@ -1110,7 +1130,7 @@ class FritzCallFBF:
                                        'Content-Length': str(len(parms))},
                        postdata=parms)
 
-       def _okReset(self, html):
+       def _okReset(self, html): #@UnusedVariable
                debug("[FritzCallFBF] _okReset")
 
        def _errorReset(self, error):
@@ -1526,7 +1546,7 @@ class FritzMenu(Screen,HelpableScreen):
 
 class FritzDisplayCalls(Screen, HelpableScreen):
 
-       def __init__(self, session, text=""):
+       def __init__(self, session, text=""): #@UnusedVariable
                if config.plugins.FritzCall.fullscreen.value:
                        self.width = DESKTOP_WIDTH
                        self.height = DESKTOP_HEIGHT
@@ -1571,7 +1591,7 @@ class FritzDisplayCalls(Screen, HelpableScreen):
                                                        self.width, self.height, _("Phone calls"),
                                                        backMainLine,
                                                        scaleH(1130, XXX), scaleV(40, XXX), scaleH(80, XXX), scaleV(26, XXX), scaleV(26, XXX), # time
-                                                       scaleH(900, XXX), scaleV(70, XXX), scaleH(310, XXX), scaleV(22, XXX), scaleV(20, XXX), # date
+                                                       scaleH(890, XXX), scaleV(70, XXX), scaleH(320, XXX), scaleV(22, XXX), scaleV(20, XXX), # date
                                                        "FritzCall " + _("Phone calls"), scaleH(500, XXX), scaleV(63, XXX), scaleH(330, XXX), scaleV(30, XXX), scaleV(27, XXX), # eLabel
                                                        scaleH(80, XXX), scaleV(150, XXX), scaleH(280, XXX), scaleV(200, XXX), scaleV(22, XXX), # statusbar
                                                        scaleH(420, XXX), scaleV(120, XXX), scaleH(790, XXX), scaleV(438, XXX), # entries
@@ -1879,6 +1899,7 @@ class FritzOfferAction(Screen):
                        self.lookup()
 
        def lookedUp(self, number, name):
+               name = handleReverseLookupResult(name)
                if not name:
                        if self.lookupState == 1:
                                name = _("No result from reverse lookup")
@@ -1886,8 +1907,8 @@ class FritzOfferAction(Screen):
                                name = _("No result from Outlook export")
                        else:
                                name = _("No result from LDIF")
-               self.number = number
                self.name = name
+               self.number = number
                debug("[FritzOfferAction] lookedUp: " + str(name.replace(", ", "\n")))
                self.setTextAndResize(str(name.replace(", ", "\n")))
 
@@ -2105,7 +2126,7 @@ class FritzCallPhonebook:
                                                                        self.width, self.height, _("Phonebook"),
                                                                        backMainLine,
                                                                        scaleH(1130, XXX), scaleV(40, XXX), scaleH(80, XXX), scaleV(26, XXX), scaleV(26, XXX), # time
-                                                                       scaleH(900, XXX), scaleV(70, XXX), scaleH(310, XXX), scaleV(22, XXX), scaleV(20, XXX), # date
+                                                                       scaleH(890, XXX), scaleV(70, XXX), scaleH(320, XXX), scaleV(22, XXX), scaleV(20, XXX), # date
                                                                        "FritzCall " + _("Phonebook"), scaleH(80, XXX), scaleV(63, XXX), scaleH(300, XXX), scaleV(30, XXX), scaleV(27, XXX), # eLabel
                                                                        scaleH(420, XXX), scaleV(120, XXX), scaleH(self.entriesWidth, XXX), scaleV(438, XXX), # entries
                                                                        scaleH(450, XXX), scaleV(588, XXX), scaleH(21, XXX), scaleV(21, XXX), # red
@@ -2407,7 +2428,7 @@ phonebook = FritzCallPhonebook()
 
 class FritzCallSetup(Screen, ConfigListScreen, HelpableScreen):
 
-       def __init__(self, session, args=None):
+       def __init__(self, session, args=None): #@UnusedVariable
                if config.plugins.FritzCall.fullscreen.value:
                        self.width = DESKTOP_WIDTH
                        self.height = DESKTOP_HEIGHT
@@ -2454,7 +2475,7 @@ class FritzCallSetup(Screen, ConfigListScreen, HelpableScreen):
                                                                self.width, self.height, _("FritzCall Setup"),
                                                                backMainLine,
                                                                scaleH(1130, XXX), scaleV(40, XXX), scaleH(80, XXX), scaleV(26, XXX), scaleV(26, XXX), # time
-                                                               scaleH(900, XXX), scaleV(70, XXX), scaleH(310, XXX), scaleV(22, XXX), scaleV(20, XXX), # date
+                                                               scaleH(890, XXX), scaleV(70, XXX), scaleH(320, XXX), scaleV(22, XXX), scaleV(20, XXX), # date
                                                                _("FritzCall Setup"), scaleH(500, XXX), scaleV(63, XXX), scaleH(330, XXX), scaleV(30, XXX), scaleV(27, XXX), # eLabel
                                                                scaleH(80, XXX), scaleV(150, XXX), scaleH(250, XXX), scaleV(200, XXX), scaleV(22, XXX), # consideration
                                                                scaleH(420, XXX), scaleV(125, XXX), scaleH(790, XXX), scaleV(428, XXX), # config
@@ -2929,6 +2950,7 @@ class FritzReverseLookupAndNotifier:
                @param caller: name and address of remote. it comes in with name, address and city separated by commas
                '''
                debug("[FritzReverseLookupAndNotifier] got: " + caller)
+               self.number = number
 #===============================================================================
 #              if not caller and os.path.exists(config.plugins.FritzCall.phonebookLocation.value + "/PhoneBook.csv"):
 #                      caller = FritzOutlookCSV.findNumber(number, config.plugins.FritzCall.phonebookLocation.value + "/PhoneBook.csv") #@UndefinedVariable
@@ -2940,8 +2962,9 @@ class FritzReverseLookupAndNotifier:
 #                      debug("[FritzReverseLookupAndNotifier] got from ldif: " + caller)
 #===============================================================================
 
-               if caller:
-                       self.caller = caller.replace(", ", "\n").replace('#','')
+               name = handleReverseLookupResult(caller)
+               if name:
+                       self.caller = name.replace(", ", "\n").replace('#','')
                        if self.number != 0 and config.plugins.FritzCall.addcallers.value and self.event == "RING":
                                debug("[FritzReverseLookupAndNotifier] add to phonebook")
                                phonebook.add(self.number, self.caller)
@@ -2964,7 +2987,7 @@ class FritzProtocol(LineReceiver):
                self.phone = None
                self.date = '0'
 
-       def notifyAndReset(self, timeout=config.plugins.FritzCall.timeout.value):
+       def notifyAndReset(self):
                notifyCall(self.event, self.date, self.number, self.caller, self.phone)
                self.resetValues()
 
@@ -3031,10 +3054,10 @@ class FritzClientFactory(ReconnectingClientFactory):
        def __init__(self):
                self.hangup_ok = False
 
-       def startedConnecting(self, connector):
+       def startedConnecting(self, connector): #@UnusedVariable
                Notifications.AddNotification(MessageBox, _("Connecting to FRITZ!Box..."), type=MessageBox.TYPE_INFO, timeout=2)
 
-       def buildProtocol(self, addr):
+       def buildProtocol(self, addr): #@UnusedVariable
                global fritzbox, phonebook
                Notifications.AddNotification(MessageBox, _("Connected to FRITZ!Box!"), type=MessageBox.TYPE_INFO, timeout=4)
                self.resetDelay()
@@ -3076,13 +3099,13 @@ class FritzCall:
                        self.d[1].disconnect()
                        self.d = None
 
-def displayCalls(session, servicelist=None):
+def displayCalls(session, servicelist=None): #@UnusedVariable
        session.open(FritzDisplayCalls)
 
-def displayPhonebook(session, servicelist=None):
+def displayPhonebook(session, servicelist=None): #@UnusedVariable
        session.open(phonebook.FritzDisplayPhonebook)
 
-def displayFBFStatus(session, servicelist=None):
+def displayFBFStatus(session, servicelist=None): #@UnusedVariable
        session.open(FritzMenu)
 
 def main(session):
@@ -3106,7 +3129,7 @@ def autostart(reason, **kwargs):
                fritz_call.shutdown()
                fritz_call = None
 
-def Plugins(**kwargs):
+def Plugins(**kwargs): #@UnusedVariable
        what = _("Display FRITZ!box-Fon calls on screen")
        what_calls = _("Phone calls")
        what_phonebook = _("Phonebook")
index a2e6879..841ae2c 100644 (file)
 <reverselookup version="1.01">
        <country code="+1">
                <website name="whitepages.com" url="http://www.whitepages.com/search/ReversePhone?phone=$NUMBER" prefix="1">
-                       <entry>
-                               <firstname>'FIRST'\s*: &quot;([^&quot;]*)&quot;,</firstname>
-                               <lastname>'LAST'\s*: &quot;([^&quot;]*)&quot;,</lastname>
-                               <street>'ADDRESS'\s*: &quot;([^&quot;]*)&quot;,</street>
-                               <city>'CITY'\s*: &quot;([^&quot;]*)&quot;,</city>
-                               <zipcode>'ZIP'\s*: &quot;([^&quot;]*)&quot;,</zipcode>
-                       </entry>
-                       <entry>
-                               <name>&lt;p class=&quot;name&quot;&gt;&lt;a href[^&gt;]*&gt;([^&lt;]*)&lt;/a&gt;&lt;/p&gt;</name>
-                               <street>&lt;li class=&quot;col_address&quot;&gt;\s*&lt;span.*?&lt;/span&gt;\s*([^&lt;\n]*)\s*&lt;/li&gt;</street>
-                               <city>&lt;li class=&quot;col_location&quot;&gt;\s*([^&lt;\n]*)\s*&lt;/li&gt;</city>
-                               <zipcode>()</zipcode>
-                       </entry>
-                       <entry>
-                               <name>&lt;a href=&quot;[^&quot;]*&quot; class=&quot;fn n&quot; title=&quot;[^&quot;]*&quot;&gt;([^&lt;]*)&lt;/a&gt;</name>
-                               <street>&lt;span class=&quot;street-address&quot;&gt;([^&lt;]*)&lt;/span&gt;</street>
-                               <city>&lt;span class=&quot;locality&quot;&gt;([^&lt;]*)&lt;/span&gt;</city>
-                               <zipcode>&lt;span class=&quot;postal-code&quot;&gt;([^&lt;]*)&lt;/span&gt;</zipcode>
-                       </entry>
-                       <entry>
-                               <name>&lt;a href=&quot;[^&quot;]*&quot; class=&quot;fn n&quot; title=&quot;[^&quot;]*&quot;&gt;([^&lt;]*)&lt;/a&gt;</name>
-                               <street>()&lt;span class=&quot;results_widget_street_none&quot;&gt;street address not available&lt;/span&gt;</street>
-                               <city>&lt;span class=&quot;locality&quot;&gt;([^&lt;]*)&lt;/span&gt;</city>
-                               <zipcode>&lt;span class=&quot;postal-code&quot;&gt;([^&lt;]*)&lt;/span&gt;</zipcode>
-                       </entry>
-                       <entry>
-                               <name>&lt;[span]*[div]* class=&quot;fn n&quot;&gt;([^&lt;]*)&lt;/[span]*[div]*&gt;</name>
-                               <street>&lt;span class=&quot;street-address&quot;&gt;([^&lt;]*)&lt;/span&gt;</street>
-                               <city>&lt;span class=&quot;locality&quot;&gt;([^&lt;]*)&lt;/span&gt;</city>
-                               <zipcode>&lt;span class=&quot;postal-code&quot;&gt;([^&lt;]*)&lt;/span&gt;</zipcode>
-                       </entry>
-                       <entry>
-                               <name>&lt;[span]*[div]* class=&quot;fn n&quot;&gt;([^&lt;]*)&lt;/[span]*[div]*&gt;</name>
-                               <street>()&lt;span class=&quot;results_widget_street_none&quot;&gt;street address not available&lt;/span&gt;</street>
-                               <city>&lt;span class=&quot;locality&quot;&gt;([^&lt;]*)&lt;/span&gt;</city>
-                               <zipcode>&lt;span class=&quot;postal-code&quot;&gt;([^&lt;]*)&lt;/span&gt;</zipcode>
+                       <entry firstOccurance="firstname">
+                               <firstname>'FIRST'\s*:\s*&quot;([^&quot;]*)&quot;,</firstname>
+                               <lastname>'LAST'\s*:\s*&quot;([^&quot;]*)&quot;,</lastname>
+                               <street>'ADDRESS'\s*:\s*&quot;([^&quot;]*)&quot;,</street>
+                               <city>'CITY'\s*:\s*&quot;([^&quot;]*)&quot;,</city>
+                               <zipcode>'ZIP'\s*:\s*&quot;([^&quot;]*)&quot;,</zipcode>
                        </entry>
                </website>
        </country>
                </website>
        </country>
        <country code="+352">
+               <website name="infobel.com" url="http://infobel.com/en/luxembourg/Inverse.aspx?qPhone=$NUMBER&amp;qSelLang3=&amp;SubmitREV=Search&amp;inphCoordType=EPSG" prefix="">
+                       <entry>
+                               <name>&lt;div class=\"result-item\"&gt;&lt;h2&gt;[^&lt;]*&lt;a [^&gt;]*&gt;([^&lt;]*)&lt;/a&gt;</name>
+                               <street>&lt;div class=\"result-box-col\"&gt;&lt;div&gt;&lt;strong&gt;([^,]*),\s*\d{4}\s*[^lt;]*&lt;/strong&gt;</street>
+                               <city>&lt;div class=\"result-box-col\"&gt;&lt;div&gt;&lt;strong&gt;[^,]*,\s*\d{4}\s*([^lt;]*)&lt;/strong&gt;</city>
+                               <zipcode>&lt;div class=\"result-box-col\"&gt;&lt;div&gt;&lt;strong&gt;[^,]*,\s*(\d{4})\s*[^lt;]*&lt;/strong&gt;</zipcode>
+                       </entry>
+               </website>
                <website name="editustel.lu" url="http://www.editustel.lu/luxweb/neosearchAT.do?input=$NUMBER" prefix="">
                        <entry>
                                <name>raisSoc[^&gt;]*&gt;([^&lt;]*?)&lt;</name>
                                <zipcode>raisSoc(?:[^&gt;]*?&gt;){6}L-(\d{4})&amp;nbsp;</zipcode>
                        </entry>
                </website>
-               <website name="infobel.com" url="http://infobel.com/en/luxembourg/Inverse.aspx?qPhone=$NUMBER&amp;qSelLang3=&amp;SubmitREV=Search&amp;inphCoordType=EPSG" prefix="">
-                       <entry>
-                               <name>ResNoPack2.&gt;&lt;tr&gt;&lt;td&gt;&lt;h3&gt;1\.\s*([^&lt;]*)&lt;</name>
-                               <street>InfoItemNoPack[^&gt;]*&gt;([^,]*),</street>
-                               <city>InfoItemNoPack[^&gt;]*&gt;[^,]*,[^\d]*\d{4}\s*([^&lt;]*)&lt;</city>
-                               <zipcode>InfoItemNoPack[^&gt;]*&gt;[^,]*,[^\d]*(\d{4})</zipcode>
-                       </entry>
-               </website>
        </country>
        <country code="+354">
                <website name="simaskra.is" url="http://ja.is/gular?q=$NUMBER" prefix="">
        </country>
        <country code="+46">
                <website name="privatpersoner.eniro.se" url="http://privatpersoner.eniro.se/query?what=wp&amp;search_word=$NUMBER&amp;geo_area=" prefix="0">
-                       <entry>
+                       <entry firstOccurance="firstname">
                                <firstname>&lt;span class=&quot;given-name&quot;&gt;([^&lt;]*)&lt;/span&gt;</firstname>
                                <lastname>&lt;span class=&quot;family-name&quot;&gt;([^&lt;]*)&lt;/span&gt;</lastname>
                                <street>&lt;span class=&quot;street-address&quot;&gt;([^&lt;]*)&lt;/span&gt;</street>
                </website>
        </country>
        <country code="+47">
-               <website name="gulesider.no" url="http://www.gulesider.no/gs/categoryList.c?q=$NUMBER" prefix="0">
+               <website name="gulesider.no" url="http://www.gulesider.no/gs/categoryList.c?q=$NUMBER" prefix="">
                        <entry>
-                               <name>RESULT.ITEM.START(?:[^&gt;]*&gt;)+([^&lt;]*?)&lt;/h2&gt;</name>
-                               <street>title=.Kart.&gt;([^,]*?),</street>
-                               <city>title=.Kart.&gt;(?:[^,]*?,)+\s*?\d{4}\s([^&lt;]*?)&lt;</city>
-                               <zipcode>title=.Kart.&gt;(?:[^,]*?,)+\s*?(\d{4})\s[^&lt;]*?&lt;</zipcode>
+                               <name swapFirstAndLastName="true">title=&quot;.*personlige infoside&quot;&gt;\s*([^&lt;]*)&lt;/a&gt;</name>
+                               <street>&lt;div\s+class=&quot;lead&quot;\s+style=&quot;padding-left: 0px;&quot;>([^,]*),\s+[^&lt;]*&lt;/div&gt;</street>
+                               <city>&lt;div\s+class=&quot;lead&quot;\s+style=&quot;padding-left: 0px;&quot;>[^,]*,\s+[^\s]*\s([^&lt;]*)&lt;/div&gt;</city>
+                               <zipcode>&lt;div\s+class=&quot;lead&quot;\s+style=&quot;padding-left: 0px;&quot;>[^,]*,\s+([^\s]*)\s[^&lt;]*&lt;/div&gt;</zipcode>
                        </entry>
                </website>
        </country>
        </country>
        <country code="+49">
                <website name="www.dasoertliche.de" url="http://dasoertliche.de/Controller?form_name=search_inv&amp;ph=$NUMBER" prefix="0">
+                       <entry firstOccurance="zipcode">
+                               <name>\sna: &quot;([^&quot;]*)&quot;,</name>
+                               <street>\sst: &quot;([^&quot;]*)&quot;,</street>
+                               <city>\sci: &quot;([^&quot;]*)&quot;,</city>
+                               <zipcode>\spc: &quot;([^&quot;]*)&quot;,</zipcode>
+                       </entry>
                <entry>
-                       <name>class=&quot;preview\s*&quot;.*?&gt;([^&lt;]*)&lt;span class="preview_box"&gt;</name>
+                       <name>class=&quot;preview&quot;&gt;([^&lt;]*)&lt;span class="preview_box"&gt;</name>
                        <street>^\s*([^,&gt;]+),&amp;nbsp;\d{5}&amp;nbsp;[^&lt;]*&lt;/div&gt;</street>
                        <city>^[^,]*,&amp;nbsp;\d{5}&amp;nbsp;([^&lt;]*)&lt;/div&gt;</city>
                        <zipcode>^[^,]*,&amp;nbsp;(\d{5})&amp;nbsp;[^&lt;]*&lt;/div&gt;</zipcode>
                        <zipcode>^[^,]*,&amp;nbsp;(\d{5})&amp;nbsp;[^&lt;]*&lt;/div&gt;</zipcode>
                </entry>
                </website>
+               <website name="www.dastelefonbuch.de" url="http://www3.dastelefonbuch.de/?la=de&amp;kw=$NUMBER&amp;cmd=detail&amp;recSelected=0" prefix="0">
+                       <entry>
+                               <name>&lt;div id=&quot;detail-hl&quot;&gt;&lt;h2&gt;([^&lt;]*)&lt;/h2&gt;</name>
+                               <street>([^&amp;]*)&amp;nbsp;&lt;br /&gt;\d{5}&amp;nbsp;[^&lt;]*&lt;/div&gt;</street>
+                               <city>[^&amp;]*&amp;nbsp;&lt;br /&gt;\d{5}&amp;nbsp;([^&lt;]*)&lt;/div&gt;</city>
+                               <zipcode>[^&amp;]*&amp;nbsp;&lt;br /&gt;(\d{5})&amp;nbsp;[^&lt;]*&lt;/div&gt;</zipcode>
+                       </entry>
+               </website>
                <website name="www.dastelefonbuch.de" url="http://www.dastelefonbuch.de/?sourceid=Mozilla-search&amp;cmd=search&amp;kw=$NUMBER" prefix="0">
                        <entry>
                                <name>&lt;div class=&quot;(?:short|long)&quot;&gt;(?:&lt;b&gt;)?&lt;a href=[^&gt;]*&gt;([^&lt;]*)&lt;</name>
                                <zipcode>&lt;td class=&quot;col3&quot;(?: onclick=&quot;[^&quot;]*&quot;)?&gt;(\d{5})</zipcode>
                        </entry>
                </website>
-<!-- this appears not to be working correctly. Klicktel tries to "guess" numbers by stripping the last digits
-               <website name="www.klicktel.de" url="http://www.klicktel.de/inverssuche/backwardssearch.html?newSearch=1&amp;boxtype=backwards&amp;vollstaendig=$NUMBER" prefix="0">
+               <website name="www.goyellow.de" url="http://www.goyellow.de/inverssuche/?TEL=$NUMBER" prefix="0">
                <entry>
-                       <name>class=&quot;title&quot;&gt;([^&lt;]+)&lt;/span&gt;</name>
-                       <street>class=&quot;location&quot;&gt;([^&lt;]+)&lt;br /&gt;\d{5}\s+[^&lt;]+&lt;/span&gt;</street>
-                       <city>class=&quot;location&quot;&gt;[^&lt;]+&lt;br /&gt;\d{5}\s+([^&lt;]+)&lt;/span&gt;</city>
-                       <zipcode>class=&quot;location&quot;&gt;[^&lt;]+&lt;br /&gt;(\d{5})\s+[^&lt;]+&lt;/span&gt;</zipcode>
+                       <name>&lt;a href=&quot;[^&quot;]*&quot; title=&quot;[^&quot;]*&quot; onClick=&quot;[^&quot;]*&quot;&gt;([^&lt;]*)&lt;/a&gt;</name>
+                               <street>&lt;p class=&quot;address&quot;&gt;([^&lt;]*)&lt;br /&gt;[\d]*\s*[^&lt;]*&lt;/p&gt;</street>
+                       <city>&lt;p class=&quot;address&quot;&gt;[^&lt;]*&lt;br /&gt;[\d]*\s*([^&lt;]*)&lt;/p&gt;</city>
+                       <zipcode>&lt;p class=&quot;address&quot;&gt;[^&lt;]*&lt;br /&gt;([\d]*)\s*[^&lt;]*&lt;/p&gt;</zipcode>
                </entry>
-               </website>
--->
-               <website name="www.goyellow.de" url="http://www.goyellow.de/inverssuche/?TEL=$NUMBER" prefix="0">
                <entry>
                        <name>&lt;a href=&quot;[^&quot;]*&quot; onClick=&quot;[^&quot;]*&quot; title=&quot;[^&quot;]*&quot;&gt;([^&lt;]*)&lt;/a&gt;</name>
                                <street>&lt;p class=&quot;address&quot;&gt;([^&lt;]*)&lt;br /&gt;[\d]*\s*[^&lt;]*&lt;/p&gt;</street>
                        <zipcode>&lt;p class=&quot;address&quot;&gt;[^&lt;]*&lt;br /&gt;([\d]*)\s*[^&lt;]*&lt;/p&gt;</zipcode>
                </entry>
                </website>
-               <website name="www.11880.com" url="http://www.11880.com/Suche/index.cfm?fuseaction=Suche.rueckwaertssucheresult&amp;init=true&amp;tel=$NUMBER" prefix="0">
+               <website name="www.11880.com" url="http://www.11880.com/Suche/index.cfm?&amp;fuseaction=Suche.rueckwaertssucheresult&amp;init=true&amp;tel=$NUMBER" prefix="0">
                <entry>
-                       <name>&lt;a style=&quot;text-decoration: underline;&quot; href=&quot;[^&quot;]*?&quot; onclick=&quot;[^&quot;]*?&quot; class=&quot;popup&quot;[^&gt;]*?&gt;([^&lt;]*?)&lt;/a&gt;</name>
+                       <name>&lt;a style=&quot;text-decoration: underline;&quot; href=&quot;[^&quot;]*?&quot;\s+onclick=&quot;[^&quot;]*?&quot;\s+class=&quot;popup&quot;[^&gt;]*?&gt;([^&lt;]*?)&lt;/a&gt;</name>
                        <street>^\t*?([^,\t]*?), [\d]{5} [^&lt;]*?&lt;br /&gt;</street>
                        <city>^\t*?[^,\t]*?, [\d]{5} ([^&lt;]*?)&lt;br /&gt;</city>
                        <zipcode>^\t*?[^,\t]*?, ([\d]{5}) [^&lt;]*?&lt;br /&gt;</zipcode>