<commit_before>import logging

log = logging.getLogger(__name__)

__all__ = ['Gateway']
		
class Gateway(object):
	"""A gateway object"""
	def __init__(self, name):
		super(Gateway, self).__init__()
		self.name = name
		self.parameters = []


	def addParameter(self, param, val):
		'''
			Set an extra parameter for a gateway
		'''
		try:
			self.getParameter(param)
		except ValueError:
			self.parameters.append({'name': param, 'value': val})
			return
		
		log.warning('Cannot replace existing parameter.')
		raise ValueError

	def getParameter(self, param):
		'''
			Retrieve the value of a parameter by its name
		'''
		for p in self.parameters:
			if p.get('name') == param:
				return p.get('value')

		raise ValueError


	def todict(self):
		'''
			Create a dict so it can be converted/serialized
		'''
		if self.parameters:
			children =[{'tag': 'param', 'attrs': p} for p in self.parameters]
		
	
		return {'tag': 'gateway', 'children': children, 'attrs': {'name': self.name}}<commit_msg>Add exception for param rtp-ip when adding parameters to gateway<commit_after>import logging

log = logging.getLogger(__name__)

__all__ = ['Gateway']
		
class Gateway(object):
	"""A gateway object"""
	def __init__(self, name):
		super(Gateway, self).__init__()
		self.name = name
		self.parameters = []


	def addParameter(self, param, val):
		'''
			Set an extra parameter for a gateway
		'''
		if param != 'rtp-ip':
			try:
				self.getParameter(param)
			except ValueError:
				self.parameters.append({'name': param, 'value': val})
				return
		else:
			self.parameters.append({'name': param, 'value': val})
                        return
		log.warning('Cannot replace existing parameter.')
		raise ValueError

	def getParameter(self, param):
		'''
			Retrieve the value of a parameter by its name
		'''
		for p in self.parameters:
			if p.get('name') == param:
				return p.get('value')

		raise ValueError


	def todict(self):
		'''
			Create a dict so it can be converted/serialized
		'''
		if self.parameters:
			children =[{'tag': 'param', 'attrs': p} for p in self.parameters]
		
	
		return {'tag': 'gateway', 'children': children, 'attrs': {'name': self.name}}
{'fraction_non_alphanumeric': 0.1433840479483633, 'fraction_numerical': 0.0, 'mean_word_length': 3.549266247379455, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3499710', 'n_tokens_mistral': 779, 'n_tokens_neox': 672, 'n_words': 211}