コード例 #1
0
ファイル: test_helper.py プロジェクト: MacGyverNL/alot
 def test_only_display_initial_letter_for_maxlength_1(self):
     short = helper.shorten_author_string(self.authors, 1)
     self.assertEqual(short, u"K")
コード例 #2
0
ファイル: test_helper.py プロジェクト: MacGyverNL/alot
 def test_replace_all_but_first_name_with_ellipses(self):
     short = helper.shorten_author_string(self.authors, 10)
     self.assertEqual(short, u"King, …")
コード例 #3
0
ファイル: test_helper.py プロジェクト: MacGyverNL/alot
 def test_shorten_first_name_with_ellipses(self):
     short = helper.shorten_author_string(self.authors, 2)
     self.assertEqual(short, u"K…")
コード例 #4
0
ファイル: test_helper.py プロジェクト: MacGyverNL/alot
 def test_shows_only_first_names_if_they_fit(self):
     short = helper.shorten_author_string(self.authors, 40)
     self.assertEqual(short, u"King, Mucho, Jaime, Flash")
コード例 #5
0
ファイル: test_helper.py プロジェクト: MacGyverNL/alot
 def test_adds_ellipses_to_long_first_names(self):
     short = helper.shorten_author_string(self.authors, 20)
     self.assertEqual(short, u"King, …, Jai…, Flash")
コード例 #6
0
ファイル: test_helper.py プロジェクト: vollkorn1982/alot
 def test_only_display_initial_letter_for_maxlength_1(self):
     short = helper.shorten_author_string(self.authors, 1)
     self.assertEqual(short, u"K")
コード例 #7
0
ファイル: test_helper.py プロジェクト: MacGyverNL/alot
 def test_high_maxlength_keeps_string_intact(self):
     short = helper.shorten_author_string(self.authors, 60)
     self.assertEqual(short, self.authors)
コード例 #8
0
ファイル: test_helper.py プロジェクト: vollkorn1982/alot
 def test_replace_all_but_first_name_with_ellipses(self):
     short = helper.shorten_author_string(self.authors, 10)
     self.assertEqual(short, u"King, …")
コード例 #9
0
ファイル: test_helper.py プロジェクト: vollkorn1982/alot
 def test_shorten_first_name_with_ellipses(self):
     short = helper.shorten_author_string(self.authors, 2)
     self.assertEqual(short, u"K…")
コード例 #10
0
ファイル: test_helper.py プロジェクト: vollkorn1982/alot
 def test_adds_ellipses_to_long_first_names(self):
     short = helper.shorten_author_string(self.authors, 20)
     self.assertEqual(short, u"King, …, Jai…, Flash")
コード例 #11
0
ファイル: test_helper.py プロジェクト: vollkorn1982/alot
 def test_shows_only_first_names_if_they_fit(self):
     short = helper.shorten_author_string(self.authors, 40)
     self.assertEqual(short, u"King, Mucho, Jaime, Flash")
コード例 #12
0
ファイル: test_helper.py プロジェクト: vollkorn1982/alot
 def test_high_maxlength_keeps_string_intact(self):
     short = helper.shorten_author_string(self.authors, 60)
     self.assertEqual(short, self.authors)
コード例 #13
0
ファイル: widgets.py プロジェクト: t-8ch/alot
    def rebuild(self):
        cols = []
        if self.thread:
            newest = self.thread.get_newest_date()
        else:
            newest = None
        if newest == None:
            datestring = ''
        else:
            datestring = settings.represent_datetime(newest)
        datestring = datestring.rjust(self.pretty_datetime_len)
        self.date_w = urwid.AttrMap(urwid.Text(datestring),
                                    self._get_theme('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),
                                         self._get_theme('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:
            if not tag_widget.hidden:
                cols.append(('fixed', tag_widget.width(), tag_widget))

        if self.thread:
            authors = self.thread.get_authors_string() or '(None)'
        else:
            authors = '(None)'
        maxlength = settings.get('authors_maxlength')
        authorsstring = shorten_author_string(authors, maxlength)
        self.authors_w = urwid.AttrMap(urwid.Text(authorsstring),
                                       self._get_theme('authors'))
        cols.append(('fixed', len(authorsstring), self.authors_w))

        if self.thread:
            subjectstring = self.thread.get_subject() or ''
        else:
            subjectstring = ''
        # sanitize subject string:
        subjectstring = subjectstring.replace('\n', ' ')
        subjectstring = subjectstring.replace('\r', '')
        subjectstring = subjectstring.strip()

        self.subject_w = urwid.AttrMap(urwid.Text(subjectstring, wrap='clip'),
                                       self._get_theme('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 = []
            # sort the most recent messages first
            msgs.sort(key=lambda msg: msg.get_date(), reverse=True)
            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'),
                self._get_theme('content'))
            cols.append(self.content_w)

        self.columns = urwid.Columns(cols, dividechars=1)
        self.original_widget = self.columns
コード例 #14
0
ファイル: widgets.py プロジェクト: laarmen/alot
    def rebuild(self):
        cols = []
        if self.thread:
            newest = self.thread.get_newest_date()
        else:
            newest = None
        if newest == None:
            datestring = ''
        else:
            formatstring = settings.get('timestamp_format')
            if formatstring is None:
                datestring = pretty_datetime(newest)
            else:
                datestring = newest.strftime(formatstring)
        datestring = datestring.rjust(self.pretty_datetime_len)
        self.date_w = urwid.AttrMap(urwid.Text(datestring),
                                    self._get_theme('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),
                                         self._get_theme('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:
            if not tag_widget.hidden:
                cols.append(('fixed', tag_widget.width(), tag_widget))

        if self.thread:
            authors = self.thread.get_authors_string() or '(None)'
        else:
            authors = '(None)'
        maxlength = settings.get('authors_maxlength')
        authorsstring = shorten_author_string(authors, maxlength)
        self.authors_w = urwid.AttrMap(urwid.Text(authorsstring),
                                       self._get_theme('authors'))
        cols.append(('fixed', len(authorsstring), self.authors_w))

        if self.thread:
            subjectstring = self.thread.get_subject() or ''
        else:
            subjectstring = ''
        # sanitize subject string:
        subjectstring = subjectstring.replace('\n', ' ')
        subjectstring = subjectstring.replace('\r', '')
        subjectstring = subjectstring.strip()

        self.subject_w = urwid.AttrMap(urwid.Text(subjectstring, wrap='clip'),
                                       self._get_theme('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'),
                                                   self._get_theme('content'))
            cols.append(self.content_w)

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