Exemplo n.º 1
0
    def get_header(self, status):
        retweeted = ''
        reply = ''
        retweet_count = ''
        retweeter = ''
        source = self.get_source(status)
        nick = self.get_nick(status)
        timer = self.get_time(status)

        if self.is_reply(status):
            reply = u' \u2709'
        if status.rt:
            retweeted = u" \u267b "
            retweeter = nick
            nick = self.origin_of_retweet(status)

        if self.get_retweet_count(status):
            retweet_count = str(self.get_retweet_count(status))

        tyrs.container['completion'].add(get_exact_nick(nick))
        header_template = self.conf.params['header_template']
        header = unicode(header_template).format(time=timer,
                                                 nick=nick,
                                                 reply=reply,
                                                 retweeted=retweeted,
                                                 source=source,
                                                 retweet_count=retweet_count,
                                                 retweeter=retweeter)

        return encode(header)
Exemplo n.º 2
0
Arquivo: widget.py Projeto: Nic0/tyrs
    def get_header(self, status):
        retweeted = ""
        reply = ""
        retweet_count = ""
        retweeter = ""
        source = self.get_source(status)
        nick = self.get_nick(status)
        timer = self.get_time(status)

        if self.is_reply(status):
            reply = u" \u2709"
        if status.rt:
            retweeted = u" \u267b "
            retweeter = nick
            nick = self.origin_of_retweet(status)

        if self.get_retweet_count(status):
            retweet_count = str(self.get_retweet_count(status))

        tyrs.container["completion"].add(get_exact_nick(nick))
        header_template = self.conf.params["header_template"]
        header = unicode(header_template).format(
            time=timer,
            nick=nick,
            reply=reply,
            retweeted=retweeted,
            source=source,
            retweet_count=retweet_count,
            retweeter=retweeter,
        )

        return encode(header)
Exemplo n.º 3
0
    def get_text(self, status):
        result = []
        text = html_unescape(status.text.replace('\n', ' '))
        if status.rt:
            text = text.split(':')[1:]
            text = ':'.join(text)

        if hasattr(status, 'retweeted_status'):
            if hasattr(status.retweeted_status, 'text') \
                    and len(status.retweeted_status.text) > 0:
                text = status.retweeted_status.text

        myself = self.api.myself.screen_name

        words = text.split(' ')
        for word in words:
            if word != '':
                word += ' '
                # The word is an HASHTAG ? '#'
                if word[0] == '#':
                    result.append(('hashtag', word))
                elif word[0] == '@':
                    ## The AT TAG is,  @myself
                    if word == '@%s ' % myself or word == '@%s: ' % myself:
                        result.append(('highlight_nick', word))
                    ## @anyone
                    else:
                        result.append(('attag', word))
                        tyrs.container['completion'].add(get_exact_nick(word))

                else:
                    result.append(word)
        return result
Exemplo n.º 4
0
Arquivo: widget.py Projeto: Nic0/tyrs
    def get_text(self, status):
        result = []
        text = html_unescape(status.text.replace("\n", " "))
        if status.rt:
            text = text.split(":")[1:]
            text = ":".join(text)

        if hasattr(status, "retweeted_status"):
            if hasattr(status.retweeted_status, "text") and len(status.retweeted_status.text) > 0:
                text = status.retweeted_status.text

        myself = self.api.myself.screen_name

        words = text.split(" ")
        for word in words:
            if word != "":
                word += " "
                # The word is an HASHTAG ? '#'
                if word[0] == "#":
                    result.append(("hashtag", word))
                elif word[0] == "@":
                    ## The AT TAG is,  @myself
                    if word == "@%s " % myself or word == "@%s: " % myself:
                        result.append(("highlight_nick", word))
                    ## @anyone
                    else:
                        result.append(("attag", word))
                        tyrs.container["completion"].add(get_exact_nick(word))

                else:
                    result.append(word)
        return result
Exemplo n.º 5
0
    def get_text(self, status):
        result = []
        text = html_unescape(status.text.replace('\n', ' '))
        if status.rt:
            text = text.split(':')[1:]
            text = ':'.join(text)

        if hasattr(status, 'retweeted_status'):
            if hasattr(status.retweeted_status, 'text') \
                    and len(status.retweeted_status.text) > 0:
                text = status.retweeted_status.text

        myself = self.api.myself.screen_name

        words = text.split(' ')
        for word in words:
            if word != '':
                word += ' '
                # The word is an HASHTAG ? '#'
                if word[0] == '#':
                    result.append(('hashtag', word))
                elif word[0] == '@':
                    ## The AT TAG is,  @myself
                    if word == '@%s ' % myself or word == '@%s: ' % myself:
                        result.append(('highlight_nick', word))
                    ## @anyone
                    else:
                        result.append(('attag', word))
                        tyrs.container['completion'].add(get_exact_nick(word))
                        
                else:
                    result.append(word)
        return result
Exemplo n.º 6
0
    def get_header(self, status):
        """Return the header text for the status associated with this widget."""
        retweeted = ''
        reply = ''
        retweet_count = ''
        retweeter = ''
        source = self.get_source(status)
        nick = self.get_nick(status)
        timer = self.get_time(status)

        if self.is_reply(status):
            reply = u' \u2709'
        if status.rt:
            retweeted = u" \u267b "
            retweeter = nick
            nick = self.origin_of_retweet(status)

        if self.get_retweet_count(status):
            retweet_count = str(self.get_retweet_count(status))
            
        tyrs.get_completion().add(get_exact_nick(nick))
        header_template = self.conf.params['header_template'] 
        header = unicode(header_template).format(
            time = timer,
            nick = nick,
            reply = reply,
            retweeted = retweeted,
            source = source,
            retweet_count = retweet_count,
            retweeter = retweeter
            )

        return encode(header)
Exemplo n.º 7
0
 def test_get_exact_nick(self):
     nick = ['@mynick', '@mynick,', '@mynick!!', 'mynick,']
     for n in nick:
         result = utils.get_exact_nick(n)
         self.assertEqual(result, 'mynick')
Exemplo n.º 8
0
 def test_get_exact_nick(self):
     nick = ['@mynick', '@mynick,', '@mynick!!', 'mynick,']
     for n in nick:
         result = utils.get_exact_nick(n)
         self.assertEqual(result, 'mynick')