<commit_before>#!/usr/bin/env python
# encoding: utf-8
"""
neighbor.py

Created by <NAME> on 2009-11-05.
Copyright (c) 2009-2011 Exa Networks. All rights reserved.
"""

from copy import copy

from bgp.structure.address import AFI
from bgp.message.open import HoldTime
from bgp.message.update.attribute.id import AttributeID

# The definition of a neighbor (from reading the configuration)
class Neighbor (object):
	def __init__ (self):
		self.description = ''
		self.router_id = None
		self.local_address = None
		self.peer_address = None
		self.peer_as = None
		self.local_as = None
		self.hold_time = HoldTime(180)
		self.graceful_restart = False
		self.md5 = None
		self.ttl = None
		self._routes = []
		self.families = []
		self._watchdog = {}

	def watchdog (self,watchdog):
		self._watchdog = copy(watchdog)

	def every_routes (self):
		return self._routes

	def filtered_routes (self):
		# This function returns a hash and not a list as "in" tests are O(n) with lists and O(1) with hash
		# and with ten thousands routes this makes an enormous difference (60 seconds to 2)
		routes = {}<commit_msg>allow to use neighbor in debugging code<commit_after>#!/usr/bin/env python
# encoding: utf-8
"""
neighbor.py

Created by <NAME> on 2009-11-05.
Copyright (c) 2009-2011 Exa Networks. All rights reserved.
"""

from copy import copy

from bgp.structure.address import AFI
from bgp.message.open import HoldTime
from bgp.message.update.attribute.id import AttributeID

# The definition of a neighbor (from reading the configuration)
class Neighbor (object):
	def __init__ (self):
		self.description = ''
		self.router_id = None
		self.local_address = None
		self.peer_address = None
		self.peer_as = None
		self.local_as = None
		self.hold_time = HoldTime(180)
		self.graceful_restart = False
		self.md5 = None
		self.ttl = None
		self.parse_routes = None
		self._routes = []
		self.families = []
		self._watchdog = {}

	def watchdog (self,watchdog):
		self._watchdog = copy(watchdog)

	def every_routes (self):
		return self._routes

	def filtered_routes (self):
		# This function returns a hash and not a list as "in" tests are O(n) with lists and O(1) with hash
		# and with ten thousands routes this makes an enormous difference (60 seconds to 2)
		routes = {}
{'fraction_non_alphanumeric': 0.09721608484312859, 'fraction_numerical': 0.02209456473707468, 'mean_word_length': 3.8898488120950323, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4912551', 'n_tokens_mistral': 808, 'n_tokens_neox': 732, 'n_words': 246}