Пример #1
0
    def episodes_to_string(self, dictionary):
        """Returns a dictionary with strings from dateobjects.

        Does the opposite of episodes_to_date(). Used to create
        strings from dateobjects, because json.dump() cannot serialize
        dateobjects.
        """
        new_dictionary = {}
        for number, dateobject in dictionary.items():
            new_dictionary[number] = utils.string_from_date(dateobject, Show.delay)
        return new_dictionary
Пример #2
0
    def episodes_to_string(self, dictionary):
        """Returns a dictionary with strings from dateobjects.

        Does the opposite of episodes_to_date(). Used to create
        strings from dateobjects, because json.dump() cannot serialize
        dateobjects.
        """
        new_dictionary = {}
        for number, dateobject in dictionary.items():
            new_dictionary[number] = utils.string_from_date(
                dateobject, Show.delay)
        return new_dictionary
Пример #3
0
    def dump_data(self):
        """Return a dictionary with the show's data.

        If there is no self.info, it dumps an "empty" dictionary
        with only the show's title.
        """
        if not self.info:
            data_dict = {
                "title": self.title,
                "season": None,
                "premiere": "",
                "end": "",
                "episodes": {}
                }
        else:
            data_dict = {
                "title": self.title,
                "season": self.season,
                "premiere": utils.string_from_date(self.premiere, Show.delay),
                "end": utils.string_from_date(self.end, Show.delay),
                "episodes": self.episodes_to_string(self.episodes)
                }
        return data_dict
Пример #4
0
    def dump_data(self):
        """Return a dictionary with the show's data.

        If there is no self.info, it dumps an "empty" dictionary
        with only the show's title.
        """
        if not self.info:
            data_dict = {
                "title": self.title,
                "season": None,
                "premiere": "",
                "end": "",
                "episodes": {}
            }
        else:
            data_dict = {
                "title": self.title,
                "season": self.season,
                "premiere": utils.string_from_date(self.premiere, Show.delay),
                "end": utils.string_from_date(self.end, Show.delay),
                "episodes": self.episodes_to_string(self.episodes)
            }
        return data_dict