regenerate the routes after a new route is added

def regenerate_routes(self):
        'regenerate the routes after a new route is added'
        for destination, origins in self.regexes.items():
            # we want only the names that match the destination regexes.
            resolved = [
                name for name in self.names
                if name is not destination
                and any(origin.search(name) for origin in origins)
            ]

            ignores = self.ignore_regexes.get(destination, [])
            for origin in resolved:
                destinations = self.routes.setdefault(origin, set())

                if any(ignore.search(origin) for ignore in ignores):
                    self.logger.info('ignoring route "%s" -> "%s"', origin, destination)
                    try:
                        destinations.remove(destination)
                        self.logger.debug('removed "%s" -> "%s"', origin, destination)
                    except KeyError:
                        pass

                    continue

                if destination not in destinations:
                    self.logger.info('added route "%s" -> "%s"', origin, destination)

                destinations.add(destination)