#!/usr/bin/env python
# coding:utf-8

import os
import sys

curr_dir = os.path.split(os.path.abspath(__file__))[0]
print("curr_dir = " + curr_dir)
sys.path.append(os.path.join(curr_dir, "../"))
sys.path.append(os.path.join(curr_dir, "../google_drive"))
sys.path.append(os.path.join(curr_dir, '../ipm'))

import config as config

from google_drive.google_sheet import GoogleSheetHelper
from ipm.wechat_alert import wechat_alert

alert = wechat_alert()

def singleton(cls):
    _instance = {}

    def inner():
        if cls not in _instance:
            _instance[cls] = cls()
        return _instance[cls]
    return inner

@singleton
class MainPlayType:
    def __init__(self):
        self.all_main_play_type_list = []
        self.debug_enable_main_play_type_list = []
        self.release_enable_main_play_type_list = []

        self.all_main_play_type_list.append('main')
        self.debug_enable_main_play_type_list.append('main')
        self.release_enable_main_play_type_list.append('main')

        # sheet_helper = GoogleSheetHelper()
        # sheet = sheet_helper.get_sheet_table(config.sheet_level_config, config.table_main_level_type)
        # sheet_datas = sheet.get_all_values(major_dimension='ROWS')
        # col_key, col_debug_enable, col_release_enable = -1, -1, -1
        # for i, row_values in enumerate(sheet_datas):
        #     if i == 0:
        #         for j, value in enumerate(row_values):
        #             if value == "key":
        #                 col_key = j + 1
        #             elif value == "debug_enable":
        #                 col_debug_enable = j + 1
        #             elif value == "release_enable":
        #                 col_release_enable = j + 1
        #     else:
        #         if col_key == -1 or col_debug_enable == -1 or col_release_enable == -1:
        #             config.notification_helper.append_msg(f"{config.sheet_level_config}文档{config.table_main_level_type}表，数据格式异常")
        #             return
        #         play_type = row_values[col_key - 1]
        #         debug_enable = row_values[col_debug_enable - 1]
        #         release_enable = row_values[col_release_enable - 1]
        #         if play_type not in self.all_main_play_type_list:
        #             self.all_main_play_type_list.append(play_type)
        #
        #         if play_type not in self.debug_enable_main_play_type_list and debug_enable == '1':
        #             self.debug_enable_main_play_type_list.append(play_type)
        #
        #         if play_type not in self.release_enable_main_play_type_list and release_enable == '1':
        #             self.release_enable_main_play_type_list.append(play_type)

