Ejemplo n.º 1
0
    def test_parse_attributes(self):
        text = '@asdf http://www.dialelo.com #asf'

        expected_result = [('attag', u'@asdf'), u' ',
                           ('url', u'http://www.dialelo.com'), u' ',
                           ('hashtag', u'#asf')]

        result = parse_attributes(text=text,
                                  hashtag='hashtag',
                                  attag='attag',
                                  url='url')
        self.assertEqual(result, expected_result)
Ejemplo n.º 2
0
Archivo: ui.py Proyecto: 1reza/turses
    def __init__(self, user, configuration):
        """
        """
        whitespace = Divider(' ')
        widgets = []

        # name
        name = Text('%s' % user.name)
        widgets.extend([name, whitespace])

        # bio
        if user.description:
            description = Text(parse_attributes(user.description))
            widgets.extend([description, whitespace])

        # URL
        if user.url:
            url_text_with_attr = ('url', user.url)
            url = Text(url_text_with_attr)

            widgets.extend([url, whitespace])

        # statistics: following, followers and favorites
        following = Text(_('following:\n%s' % user.friends_count))
        followers = Text(_('followers:\n%s' % user.followers_count))
        favorites = Text(_('favorites:\n%s' % user.favorites_count))
        stats = Columns([following, followers, favorites])

        widgets.extend([stats, whitespace])

        # last status
        if user.status:
            status = StatusWidget(user.status, configuration)
            widgets.append(status)

        pile = Pile(widgets)

        WidgetWrap.__init__(self, LineBox(title='@%s' % user.screen_name,
                                          original_widget=pile))