def handle_detail_common_rule(self, matrix, content):

		rules = content['rule']
		name = content['param']

		for rule in rules:
			if check_cond(rule['cond'], matrix):
				matrix['content'][name] = rule['value']
				break
	def ask_user(self, question, matrix):
		if check_cond(question['cond'], matrix):
			ques = question['ask']

			print '\nPlease answer the questions based on \'%s\' ...' % matrix['model']
			print bcolors.WARNING + ques + bcolors.NORMAL
			if question.has_key('range'):
				print '(range is %s)' % question['range']
			ans = raw_input()
			while not self.check_answer(ques, ans):
				ans = raw_input()

			#question['ans'] = ans
			qid = question['id']
			matrix['answer'][qid] = ans
	def action(self):

		stain = False

		elements = self.elements
		et_object = self.et_object

		for element in elements:
			if element.has_key('cond') and not check_cond(element['cond'], self.matrix):
				continue

			if debug:
				print json.dumps(element, indent=4, sort_keys=True)

			stain = stain | self.detail_action(et_object, element)

		if stain:
			return True
		else:
			return False
	def parse_detail_api_rule(self, matrix, specs):

		for spec in specs:
			questions = []
			tasks = []

			if spec.has_key('ques'):
				questions = spec['ques']

			if spec.has_key('task'):
				tasks = spec['task']

			# format or update 
			if config.g_format:
				for task in tasks:
					matrix['action'] = matrix['action'] + task['action']
			else:
				for question in questions:
					self.ask_user(question, matrix)

				for task in tasks:
					if check_cond(task['cond'], matrix):
						matrix['action'] = matrix['action'] + task['action']