def schedule_hours() -> list:
    """
    Retrieves the weekly cleanup-hour schedule from the document_name
    and formats the table into a list of CleanupHour objects
    :rtype: list
    :return: list of CleanupHour objects
    """
    client = get_google_creds()
    sheet = client.open(DOCUMENT_NAME).get_worksheet(1)
    all_values = sheet.get_all_values()
    col_one = sheet.col_values(1)
    max_row = len(col_one)
    hours_list = []
    for i in range(1, max_row):
        row = all_values[i]
        name = row[0]
        task_id = row[1]
        day = row[2]
        due_time = row[3]
        worth = row[4]
        difficulty = row[5]
        link = row[6]
        hour = CleanupHour(name, task_id, day, due_time, worth, difficulty, link)
        # print(hour)
        hours_list.append(hour)
    return hours_list
def generate_members() -> list:
    """
    Generates a list of Member objects from the document_NAME. Each member's
    data is extracted and stored in a Member. Running total of hours is accessed by
    calling the generate_hours method
    :rtype: list
    :return: list of Member objects
    """

    hours_dict = generate_hours()
    skips_dict = generate_skips()
    client = get_google_creds()
    sheet = client.open(DOCUMENT_NAME).get_worksheet(2)
    all_values = sheet.get_all_values()
    col_one = sheet.col_values(1)
    max_row = len(col_one)
    members = []
    for i in range(1, max_row):
        member_row = all_values[i]
        name_first = member_row[0]
        name_last = member_row[1]
        phone = member_row[2]
        email = member_row[3]
        status = member_row[4]
        active = 'TRUE' in member_row[5]
        hours = hours_dict.get(name_first.strip() + name_last.strip(), -1)
        skips = skips_dict.get(name_first.strip() + name_last.strip(), -1)
        member = Member(name_first, name_last, phone, email, status, active,
                        hours, skips)
        members.append(member)
        print(member)
    return members
def generate_skips():
    client = get_google_creds()
    sheet = client.open(DOCUMENT_NAME).get_worksheet(3)
    all_values = sheet.get_all_values()
    col_one = sheet.col_values(1)
    max_row = len(col_one)
    skips_dict = {}
    for i in range(1, max_row):
        member_row = all_values[i]
        skips_dict[member_row[0].strip() + member_row[1].strip()] = int(
            member_row[3])
    return skips_dict
def generate_hours() -> dict:
    """
    Retrieves the running total of hours for all members from the document_name
    The values are stored in a dictionary where the key is the member's first and last name combined
    :rtype: dict
    :return: dict of hours mapping value 'hours' to key 'last name'
    """
    client = get_google_creds()
    sheet = client.open(DOCUMENT_NAME).get_worksheet(3)
    all_values = sheet.get_all_values()
    col_one = sheet.col_values(1)
    max_row = len(col_one)
    hours_dict = {}
    for i in range(1, max_row):
        member_row = all_values[i]
        hours_dict[member_row[0].strip() +
                   member_row[1].strip()] = member_row[2]
    return hours_dict
 def generate_floor_plan():
     """
     Floor plan is a dictionary that maps a first name and last name concatenated (no space) to the floor
     the member lives on
     :return: the dictionary of mappings
     """
     client = get_google_creds()
     sheet = client.open(DOCUMENT_NAME).get_worksheet(4)
     all_values = sheet.get_all_values()
     col_one = sheet.col_values(1)
     max_row = len(col_one)
     members = {}
     for i in range(1, max_row):
         member_row = all_values[i]
         name_first = member_row[FIRST_COL].strip()
         name_last = member_row[LAST_COL].strip()
         member = Member.query.filter_by(first=name_first, last=name_last).first()
         if member is None:
             raise ValueError("Member " + name_first + " " + name_last + " is in the floor plan but not in the"
                                                                         + " members list. Please remove him from "
                                                                           "the floor plan or add to the list.")
         bathroom = member_row[BATHROOM_COL].strip()
         members[member.first + member.last] = bathroom
     return members