def __init__(self, session, cond_dict):
		self.session = session
		assert_type(cond_dict, dict, "condition specification")

		try:
			self.cond_type = cond_dict['type']
		except KeyError:
			raise InvalidScenarioFileFormat("Encountered condition without type\n"+str(cond_dict))
		try:
			self.callback = CONDITIONS.get(self.cond_type)
		except KeyError:
			raise InvalidScenarioFileFormat('Found invalid condition type: %s' % self.cond_type)

		self.arguments = cond_dict.get('arguments', [])
	def __init__(self, session, cond_dict):
		self.session = session
		if not 'type' in cond_dict:
			raise InvalidScenarioFileFormat("Encountered condition without type")
		try:
			self.cond_type = CONDITIONS.get_item_for_string(cond_dict['type'])
		except KeyError:
			raise InvalidScenarioFileFormat('Found invalid condition type: %s' % cond_dict['type'])
		# first check the global namespace for a function called same as the condition.
		# if a function has to be named differently, map the CONDITION type in self.condition_types
		if cond_dict['type'] in globals():
			self.callback = globals()[cond_dict['type']]
		else:
			self.callback = self.condition_types[ self.cond_type  ]
		self.arguments = cond_dict['arguments'] if 'arguments' in cond_dict else []
Example #3
0
 def __init__(self, session, cond_dict):
     self.session = session
     if not 'type' in cond_dict:
         raise InvalidScenarioFileFormat(
             "Encountered condition without type")
     try:
         self.cond_type = CONDITIONS.get_item_for_string(cond_dict['type'])
     except KeyError:
         raise InvalidScenarioFileFormat(
             'Found invalid condition type: %s' % cond_dict['type'])
     # first check the global namespace for a function called same as the condition.
     # if a function has to be named differently, map the CONDITION type in self.condition_types
     if cond_dict['type'] in globals():
         self.callback = globals()[cond_dict['type']]
     else:
         self.callback = self.condition_types[self.cond_type]
     self.arguments = cond_dict[
         'arguments'] if 'arguments' in cond_dict else []
def print_scenario_conditions():
	print('Available scenario conditions and their arguments:')
	for condition in CONDITIONS.registry:
		arguments = inspect.getargspec(CONDITIONS.get(condition))[0][1:] # exclude session
		print('{:-36s}  {}'.format(condition, arguments or ''))
Example #5
0
def print_scenario_conditions():
	print('Available scenario conditions and their arguments:')
	for condition in CONDITIONS.registry:
		arguments = inspect.getargspec(CONDITIONS.get(condition))[0][1:] # exclude session
		print('{:-36s}  {}'.format(condition, arguments or ''))