Ejemplo n.º 1
0
 def get_datestring(self):
     """returns formated datestring"""
     formatstring = config.get('general', 'timestamp_format')
     if formatstring:
         res = self._datetime.strftime(formatstring)
     else:
         res = helper.pretty_datetime(self._datetime)
     return res
Ejemplo n.º 2
0
    def get_datestring(self):
        """
        returns reformated datestring for this messages.

        It uses the format spacified by `timestamp_format` in
        the general section of the config.
        """
        if self._datetime == None:
            return None
        if config.has_option('general', 'timestamp_format'):
            formatstring = config.get('general', 'timestamp_format')
            res = self._datetime.strftime(formatstring)
        else:
            res = helper.pretty_datetime(self._datetime)
        return res
Ejemplo n.º 3
0
    def rebuild(self):
        cols = []
        formatstring = config.get('general', 'timestamp_format')
        newest = self.thread.get_newest_date()
        if formatstring:
            datestring = newest.strftime(formatstring)
        else:
            datestring = pretty_datetime(newest).rjust(10)
        self.date_w = urwid.AttrMap(urwid.Text(datestring), 'threadline_date')
        cols.append(('fixed', len(datestring), self.date_w))

        mailcountstring = "(%d)" % self.thread.get_total_messages()
        self.mailcount_w = urwid.AttrMap(urwid.Text(mailcountstring),
                                   'threadline_mailcount')
        cols.append(('fixed', len(mailcountstring), self.mailcount_w))

        tags = self.thread.get_tags()
        tags.sort()
        for tag in tags:
            tw = TagWidget(tag)
            self.tag_widgets.append(tw)
            cols.append(('fixed', tw.width(), tw))

        authors = self.thread.get_authors() or '(None)'
        maxlength = config.getint('general', 'authors_maxlength')
        authorsstring = shorten(authors, maxlength).strip()
        self.authors_w = urwid.AttrMap(urwid.Text(authorsstring),
                                       'threadline_authors')
        cols.append(('fixed', len(authorsstring), self.authors_w))

        subjectstring = self.thread.get_subject().strip()
        self.subject_w = urwid.AttrMap(urwid.Text(subjectstring, wrap='clip'),
                                 'threadline_subject')
        if subjectstring:
            cols.append(('fixed', len(subjectstring), self.subject_w))

        if self.display_content:
            msgs = self.thread.get_messages().keys()
            msgs.sort()
            lastcontent = ' '.join([m.get_text_content() for m in msgs])
            contentstring = lastcontent.replace('\n', ' ').strip()
            self.content_w = urwid.AttrMap(urwid.Text(contentstring,
                                                      wrap='clip'),
                                           'threadline_content')
            cols.append(self.content_w)

        self.columns = urwid.Columns(cols, dividechars=1)
        self.original_widget = self.columns
Ejemplo n.º 4
0
    def rebuild(self):
        cols = []
        # DATE
        formatstring = config.get('general', 'timestamp_format')
        newest = self.thread.get_newest_date()
        if formatstring:
            datestring = newest.strftime(formatstring)
        else:
            datestring = pretty_datetime(newest).rjust(10)
        self.date_w = urwid.AttrMap(urwid.Text(datestring), 'threadline_date')

        # SIZE
        thread_size = self.thread.get_total_messages()
        # Show number of messages only if there are at least 2 mails
        # (save space in the line)
        if thread_size>1 and thread_size<=20:
            charcode = 0x2474 + thread_size
            mailcountstring = unichr(charcode)
        elif thread_size>1 and thread_size>20: 
            mailcountstring = "(%d)" % thread_size
        else:
            mailcountstring = " "

        # TAGS
        tags = self.thread.get_tags()
        tags.sort()
        tagstrings = []
        for tag in tags:
            tw = TagWidget(tag)
            self.tag_widgets.append(tw)
            tagstrings.append(('fixed', tw.width(), tw))
            
        # AUTHORS
        authors_string = self.thread.get_authors() or '(None)'
        maxlength = config.getint('general', 'authors_maxlength')
        authorsstring = shorten_author_string(authors_string, maxlength - len(mailcountstring))
        offset = maxlength - len(authorsstring)
        mailcountstring = mailcountstring.rjust(offset)
        self.mailcount_w = urwid.AttrMap(urwid.Text(mailcountstring),
                                   'threadline_mailcount')

        self.authors_w = urwid.AttrMap(urwid.Text(authorsstring),
                                       'threadline_authors')

        # SUBJECT
        subjectstring = self.thread.get_subject().strip()
        self.subject_w = urwid.AttrMap(urwid.Text(subjectstring, wrap='clip'),
                                 'threadline_subject')

        # BODY
        if self.display_content:
            msgs = self.thread.get_messages().keys()
            msgs.sort()
            lastcontent = ' '.join([m.get_text_content() for m in msgs])
            contentstring = lastcontent.replace('\n', ' ').strip()
            self.content_w = urwid.AttrMap(urwid.Text(contentstring,
                                                      wrap='clip'),
                                           'threadline_content')

        # Set column order
        #self.select = urwid.AttrMap(urwid.Text("[ ] ", wrap='clip'),
        #                            'threadline_subject')
        #cols.append(('fixed', 4, self.select))
        cols.append(('fixed', len(datestring), self.date_w))
        cols.append(('fixed', len(authorsstring), self.authors_w))
        cols.append(('fixed', len(mailcountstring), self.mailcount_w))

        cols.extend(tagstrings)

        if subjectstring:
            cols.append(('fixed', len(subjectstring), self.subject_w))
        if self.display_content:
            cols.append(self.content_w)

        self.columns = urwid.Columns(cols, dividechars=1)
        self.original_widget = self.columns
Ejemplo n.º 5
0
    def rebuild(self):
        cols = []
        if self.thread:
            newest = self.thread.get_newest_date()
        else:
            newest = None
        if newest == None:
            datestring = u' ' * 10
        else:
            formatstring = config.get('general', 'timestamp_format')
            if formatstring:
                datestring = newest.strftime(formatstring)
            else:
                datestring = pretty_datetime(newest).rjust(10)
        self.date_w = urwid.AttrMap(urwid.Text(datestring),
                                    'search_thread_date')
        cols.append(('fixed', len(datestring), self.date_w))

        if self.thread:
            mailcountstring = "(%d)" % self.thread.get_total_messages()
        else:
            mailcountstring = "(?)"
        self.mailcount_w = urwid.AttrMap(urwid.Text(mailcountstring),
                                   'search_thread_mailcount')
        cols.append(('fixed', len(mailcountstring), self.mailcount_w))

        if self.thread:
            self.tag_widgets = [TagWidget(t) for t in self.thread.get_tags()]
        else:
            self.tag_widgets = []
        self.tag_widgets.sort(tag_cmp,
                              lambda tag_widget: tag_widget.translated)
        for tag_widget in self.tag_widgets:
            cols.append(('fixed', tag_widget.width(), tag_widget))

        if self.thread:
            authors = self.thread.get_authors() or '(None)'
        else:
            authors = '(None)'
        maxlength = config.getint('general', 'authors_maxlength')
        authorsstring = shorten_author_string(authors, maxlength)
        self.authors_w = urwid.AttrMap(urwid.Text(authorsstring),
                                       'search_thread_authors')
        cols.append(('fixed', len(authorsstring), self.authors_w))

        if self.thread:
            subjectstring = self.thread.get_subject().strip()
        else:
            subjectstring = ''
        self.subject_w = urwid.AttrMap(urwid.Text(subjectstring, wrap='clip'),
                                 'search_thread_subject')
        if subjectstring:
            cols.append(('weight', 2, self.subject_w))

        if self.display_content:
            if self.thread:
                msgs = self.thread.get_messages().keys()
            else:
                msgs = []
            msgs.sort()
            lastcontent = ' '.join([m.get_text_content() for m in msgs])
            contentstring = lastcontent.replace('\n', ' ').strip()
            self.content_w = urwid.AttrMap(urwid.Text(contentstring,
                                                      wrap='clip'),
                                           'search_thread_content')
            cols.append(self.content_w)

        self.columns = urwid.Columns(cols, dividechars=1)
        self.original_widget = self.columns