def remove_router_references(self, adapter, address=None):
        if _debug: NetworkServiceAccessPoint._debug("remove_router_references %r %r", adapter, address)

        delrlist = []
        delnlist = []
        # scan through the dictionary of router references
        for rkey in self.routers.keys():
            # rip apart the key
            radapter, raddress = rkey

            # pick all references on the adapter, optionally limited to a specific address
            match = radapter is adapter
            if match and address is not None:
                match = (raddress == address)
            if not match:
                continue

            # save it for deletion
            delrlist.append(rkey)
            delnlist.extend(self.routers[rkey].networks)
        if _debug:
            NetworkServiceAccessPoint._debug("    - delrlist: %r", delrlist)
            NetworkServiceAccessPoint._debug("    - delnlist: %r", delnlist)

        # delete the entries
        for rkey in delrlist:
            try:
                del self.routers[rkey]
            except KeyError:
                if _debug: NetworkServiceAccessPoint._debug("    - rkey not in self.routers: %r", rkey)
        for nkey in delnlist:
            try:
                del self.networks[nkey]
            except KeyError:
                if _debug: NetworkServiceAccessPoint._debug("    - nkey not in self.networks: %r", rkey)

    #-----
Add/update references to routers.
dataset/ETHPy150Open JoelBender/bacpypes/py25/bacpypes/netservice.py/NetworkServiceAccessPoint.remove_router_references