Ejemplo n.º 1
0
    def get_results(
            self,
            worksheet: gspread.models.Worksheet) -> (int, int, float, str):
        """
        プレイヤの戦績を取得
        @param worksheet: ワークシートオブジェクト
        @return num_game: 試合数
        @return num_win: 勝利数
        @return winning_rate: 勝率
        @return average: 平均スコア
        """
        num_game = int(worksheet.cell(self.row, 2).value)
        num_win = int(worksheet.cell(self.row, 3).value)
        winning_rate = None
        average = worksheet.cell(self.row, 11).value

        if num_game > 0:
            winning_rate = num_win / num_game

        self.num_game = num_game
        self.num_win = num_win
        self.winning_rate = winning_rate
        self.average = average

        return num_game, num_win, winning_rate, average
Ejemplo n.º 2
0
def update_uploaded_status(sheet: gspread.models.Worksheet,
                           uploaded_rows: List[int]):
    if len(uploaded_rows) == 0:
        return
    cells = [
        Cell(row=row, col=UPLOADED_COLUMN, value="TRUE")
        for row in uploaded_rows
    ]
    sheet.update_cells(cells, value_input_option="USER_ENTERED")
Ejemplo n.º 3
0
def firstEmptyCell(worksheet: gspread.models.Worksheet,
                   coordType: str,
                   coord: int,
                   header=True):
    if coordType != "col" and coordType != "row":
        Exception("This function's 'coordType' must be either 'col' or 'row'.")

    tmp = worksheet.col_values(
        coord) if coordType == "col" else worksheet.row_values(coord)
    if header: tmp.pop(0)
    result = len(tmp) + 2 if header else len(tmp) + 1

    return result
Ejemplo n.º 4
0
def store_config_calendar(sheet: gspread.models.Worksheet):

    info = sheet.get_all_values()[4:]
    for calendar_link, calendar_image, color in info:
        config['calendar']['calendarlink'] = calendar_link
        config['calendar']['calendarimage'] = calendar_image
        config['calendar']['color'] = color
Ejemplo n.º 5
0
def store_config_game_managers(sheet: gspread.models.Worksheet):

    gm_dir_info = sheet.get_all_values()[4:]

    for i, gm in enumerate(gm_dir_info):
        for j, info in enumerate(gm):
            config[f'gm-info-{j + 1}'][str(i + 1)] = str(info).replace(
                "%", "<>")
Ejemplo n.º 6
0
 def get_name(self, worksheet: gspread.models.Worksheet) -> str:
     """
     プレイヤ名を取得
     @param worksheet: ワークシートオブジェクト
     @return name: プレイヤ名
     """
     name = worksheet.cell(1, self.column).value
     self.name = name
     return name
Ejemplo n.º 7
0
def get_dataframe(sheet: gspread.models.Worksheet) -> pd.DataFrame:
    column_names = [
        "Resource Name", "Category", "Tags", "Club/Organization",
        "Description", "Website", "Image Link", "Facebook", "Card Link",
        "iOS Link", "Android Link", "Ready for Upload", "Uploaded"
    ]
    FIRST_ROW = 8
    return pd.DataFrame(sheet.get_all_values(),
                        columns=column_names).iloc[FIRST_ROW:]
Ejemplo n.º 8
0
def store_config_faq(sheet: gspread.models.Worksheet):

    q_and_a = sheet.get_all_values()[4:]

    questions = [i[0] for i in q_and_a]
    answers = [i[1] for i in q_and_a]

    for i in range(len(q_and_a)):
        config['faq'][str(questions[i])] = str(answers[i])
Ejemplo n.º 9
0
def store_config_reserved_pcs_blue(sheet: gspread.models.Worksheet):

    blue_room_values = sheet.get_all_values()[4:]
    reserved_pcs = [i[1] for i in blue_room_values]  # Col 2
    descriptions = [i[2] for i in blue_room_values]  # Col 3
    # Column 1 is reserved for PC numbers- these are nonfunctional labels for users

    config['lab-blue-description']['content'] = descriptions[0]
    for i, pc in enumerate(reserved_pcs):
        config['lab-blue-reservations'][str(i + 1)] = pc
Ejemplo n.º 10
0
def store_help_directory_config(sheet: gspread.models.Worksheet):
    """
    :param sheet: help directory sheet
    :return: None
    """

    help_dir_info = sheet.get_all_values()[4:]
    for i, leader in enumerate(help_dir_info):
        for j, info in enumerate(leader):
            config[f'contact-info-{j+1}'][str(i + 1)] = info
Ejemplo n.º 11
0
def store_config_supported_games(sheet: gspread.models.Worksheet):

    supported_games = sheet.get_all_values()[4:]

    role_names = [i[0] for i in supported_games]
    emoji_names = [i[1] for i in supported_games]

    for i in range(len(supported_games)):
        config['role-games'][configutil.get_key_name_as_convention(
            role_names[i])] = str(role_names[i])
        config['emoji-games'][configutil.get_key_name_as_convention(
            emoji_names[i])] = str(emoji_names[i])
Ejemplo n.º 12
0
    def get_results(self,
                    worksheet: gspread.models.Worksheet) -> (int, int, float):
        """
        プレイヤの戦績を取得
        @param worksheet: ワークシートオブジェクト
        @return num_game: 試合数
        @return num_win: 勝利数
        @return winning_rate: 勝率
        """
        num_game = int(worksheet.cell(2, self.column).value)
        num_win = int(worksheet.cell(6, self.column).value)
        winning_rate = None

        if num_game > 0:
            winning_rate = num_win / num_game

        self.num_game = num_game
        self.num_win = num_win
        self.winning_rate = winning_rate

        return num_game, num_win, winning_rate
Ejemplo n.º 13
0
def store_config_event_subs(sheet: gspread.models.Worksheet):

    event_subs = sheet.get_all_values()[4:]
    role_names = [i[0] for i in event_subs]  # Col 2
    emoji_names = [i[1] for i in event_subs]
    description = [i[2] for i in event_subs]

    for i, item in enumerate(event_subs):
        key = configutil.get_key_name_as_convention(role_names[i])
        config['role-events'][key] = str(role_names[i])
        config['emoji-events'][key] = str(emoji_names[i])
        config['description-events'][key] = str(description[i])
Ejemplo n.º 14
0
 def getwsheetdata(cls, wsheet: gspread.models.Worksheet) -> List[dict]:
     res = []
     if wsheet is not None:
         try:
             res = wsheet.get_all_records()
         except IndexError:
             flash(
                 f"Erreur : Onglet {wsheet.title} du fichier {wsheet.spreadsheet.title} vide"
             )
         except Exception as ex:
             flash(f"Erreur : {ex}")
     return res
Ejemplo n.º 15
0
def store_config_authed_users(sheet: gspread.models.Worksheet):

    authed_users = sheet.get_all_values()[4:]
    for i, users in enumerate(authed_users):
        config['id-authed'][f'{i+1}'] = str(users[1])
Ejemplo n.º 16
0
def __get_roundabout(wks: gspread.models.Worksheet):
    val = wks.acell(cell_ROUNDABOUT).value
    val = re.sub(r'\D', '', val)  # d only
    return int(val)  # type int
Ejemplo n.º 17
0
def store_config_channels(sheet: gspread.models.Worksheet):

    channel_names = sheet.get_all_values()[4:]
    for i, channel_name in enumerate(channel_names):
        as_key = str(channel_name[1]).replace("-", "")
        config['channel'][as_key] = str(channel_name[1])
Ejemplo n.º 18
0
def get_dataframe(sheet: gspread.models.Worksheet) -> pd.DataFrame:
    df = pd.DataFrame(sheet.get_all_values())
    header = df.iloc[0]
    df = df[1:]
    df.columns = header
    return df