示例#1
0
def sync_lang(sheet: Worksheet):
    raw_sheet_lang = sheet.row_values(1)
    sheet_lang = set(raw_sheet_lang)
    origin_lang = set(language_pack.languages)
    empty_langs = origin_lang - sheet_lang
    if empty_langs:
        data = [raw_sheet_lang + list(empty_langs)]
        acell = f'A1:{ascii_uppercase[len(data[0]) - 1]}1'
        print(f'update {acell} to ', data)
        sheet.update(acell, data)
    def __enter_data_on_sheet(self, ws: gspread.Worksheet) -> tuple:
        """
        This *private* method enters the data into the worksheet.

        :param ws: the one Google Worksheet in the file
        :return:
        """
        if self.__data_list:
            data = [self.__header_list[2]] + self.__data_list
        else:
            data = [self.__header_list[2]]

        try:
            response = ws.update('A1', data, raw=False)
            return True, ''
        except Exception as e:
            return False, 'There was an error entering the data on the Google Sheet.'