Ejemplo n.º 1
0
    def __init__(self,
                 current_date,
                 media_handler,
                 previous_date=None,
                 following_date=None):
        """Initializes a new HTMLTLWriter for a current day which outputs to
           out_file_func(current_date).

           A media handler must be given so the generated files know where
           to look for, for example, images, profile pictures, etc.

           Two optional previous/following dates parameters can be given which
           dates should correspond to the previous and following days"""
        self.current_date = current_date
        self.formatter = HTMLFormatter(media_handler)

        # Open the current output file and store its handle
        output_file = media_handler.get_html_path(current_date)
        makedirs(dirname(output_file), exist_ok=True)
        self.handle = open(output_file, 'w', encoding='utf-8')

        # Begin the header before writing any Telegram message
        self.start_header(current_date=current_date,
                          previous_date=previous_date,
                          following_date=following_date)