Esempio n. 1
0
    def do_prof_response(self, command_list):
        if not command_list:
            self.write_text(self.lt_sheets.sheet_to_simple_response("prof"))
        else:

            prof_name = " ".join(command_list)

            curr_time = datetime.datetime.today()
            prev_time = curr_time - datetime.timedelta(days=1)
            next_time = curr_time - datetime.timedelta(days=-1)

            day_code_list = Stevens.get_day_code_list([
                prev_time.strftime("%A"),
                curr_time.strftime("%A"),
                next_time.strftime("%A")
            ])

            found_prof_section_list_dict = {}
            for prof_key in self.stevens.prof_section_list_dict:
                if prof_name.lower() in prof_key.lower():
                    found_prof_section_list_dict[
                        prof_key] = self.stevens.prof_section_list_dict[
                            prof_key]

            if len(found_prof_section_list_dict) == 0:
                self.write_text("No professor found")
            elif len(found_prof_section_list_dict) > 1:
                str_ret = "Multiple professors found:"
                for found_prof_key in found_prof_section_list_dict:
                    str_ret += "\n{}{}".format(Constants.groupme_tab,
                                               found_prof_key)
                self.write_text(str_ret)
            else:
                str_ret = ""
                for found_prof_key in found_prof_section_list_dict:
                    str_ret += "Professor found: {}".format(found_prof_key)
                    filtered_section_list = []
                    for section in found_prof_section_list_dict[
                            found_prof_key]:
                        if section.day.lower() in day_code_list:
                            filtered_section_list.append(section)

                    if len(filtered_section_list) == 0:
                        str_ret += "\n{}No sections found with day codes [{}]".format(
                            Constants.groupme_tab, ", ".join(day_code_list))
                    else:
                        for section in filtered_section_list:
                            str_ret += "\n{}Room: {}  |  {}: {} - {}".format(
                                Constants.groupme_tab, section.room.name,
                                Stevens.get_day_from_code(
                                    section.day).title()[:3],
                                Functions.get_nice_time_format(
                                    section.start_time),
                                Functions.get_nice_time_format(
                                    section.end_time))

                self.write_text(str_ret)
Esempio n. 2
0
def section_list_to_string(section_list):
    str_ret = ""
    for i, section in enumerate(section_list):
        if i != 0:
            str_ret += "\n"
        str_ret += "{}: {} - {} | {} ({})".format(
            get_day_from_code(section.day.lower())[:3].title(),
            Functions.get_nice_time_format(section.start_time),
            Functions.get_nice_time_format(section.end_time),
            section.course_name, section.professor)
    return str_ret
Esempio n. 3
0
 def __str__(self):
     return "{} - {}".format(
         Functions.get_nice_time_format(self.start_time),
         Functions.get_nice_time_format(self.end_time))