def __get_config(config_file=None):
	""" module checks for the config file and converts the json to dict """
	config_file = os.path.join(config_path, config_file)

	if not os_util().check_if_file_exist(config_file):
		sys.exit()
	return __json_to_dict(config_file)
def __excel_to_dict(test_xl_file=None):
	""" reads the test_case excel files and store it in dictionary """
	test_xl_file = os.path.join(test_case_xl_path, test_xl_file)

	if not os_util().check_if_file_exist(test_xl_file):
		sys.exit()

	wb = openpyxl.load_workbook(test_xl_file, read_only=True)
	sheet = wb.get_sheet_by_name('Sheet1')
	tc_dict = {}
	total_sheet_row = sheet.get_highest_row()

	for row in range(2, total_sheet_row+1):
		try:
			tc_id = sheet['A' + str(row)].value
			tc_desc = sheet['B' + str(row)].value
			tc_values = dict(tc_desc=str(tc_desc), result='')
		except Exception:
			log.error("decode error", exc_info=True)
			sys.exit()
		try:
			tc_dict[int(tc_id)]=tc_values
		except KeyError:
			log.info("key error, %s, %s" %(tc_id, tc_desc))
			pass

	if len(tc_dict) == 0:
		log.error("testcase file is empty")
		sys.exit()
	else:
		log.debug("Test cases = \n %s" % pprint.pformat(tc_dict, indent=4))

	log.info('copying the test cases excel file to result path ')
	os.system('cp %s %s' % (test_xl_file, result_path))
	return tc_dict
def __dict_to_excel(test_xl_file, tc_dict=None):
	""" write the result in the excel sheet """
	test_xl_file = os.path.join(result_path, test_xl_file)

	if not os_util().check_if_file_exist(test_xl_file):
		sys.exit()

	wb = openpyxl.load_workbook(test_xl_file)
	sheet = wb.get_sheet_by_name('Sheet1')
	total_sheet_row = sheet.get_highest_row()
	arial_font = Font(name='Arial', size=10, italic=False, bold=True, shadow=False)
	style_obj = Style(font=arial_font)
	sheet['C1'].style = style_obj
	sheet['C1'] = "Result"

	def _color_for_result(result):
		if result == 1:
			result_font = Font(name='Arial', size=10, bold=True, shadow=False, color='00003300')
			return Style(font=result_font), 'PASSED'
		elif result == 0:
			result_font = Font(name='Arial', size=10, bold=True, shadow=False, color='00FF0000')
			return Style(font=result_font), 'FAILED'
		else:
			result_font = Font(name='Arial', size=10, bold=True, shadow=False, color='000000FF')
			return Style(font=result_font), 'EXCEPTION'

	for row in range(2, total_sheet_row+1):
		try:
			tc_id = int(sheet['A' + str(row)].value)
			tc_result = _color_for_result(tc_dict[tc_id]['result'])
			sheet['C%s' % str(row)].style = tc_result[0]
			sheet['C%s' % str(row)] = tc_result[1]
		except Exception:
			log.error("decode error", exc_info=True)

	wb.save(test_xl_file)