示例#1
0
 def __init__(self, n, limit):
     Label.__init__(self,
         "Sorry, your query had too many (%s) results! The current "
         "supported limit is %s." % (
                        utils.splitthousands(n),
                        utils.splitthousands(limit)),
         StyleName='userlist-error-title')
示例#2
0
 def __init__(self, names, limit):
     VerticalPanel.__init__(self, Spacing=8, StyleName='userlist-error-box')
     self.add(Label(
         "The following people have too many friends! The current "
         "supported limit is %s." % utils.splitthousands(limit),
         StyleName='userlist-error-title'))
     s = []
     for name, friends in names:
         n = utils.splitthousands(friends)
         s.append('%s (%s friends)' % (
             utils.screennameToTwitterLink(name),
             utils.screennameToTwitterFriendsLink(name, n)))
     self.add(HTML('<br/>'.join(s), StyleName='userlist-error-text'))
示例#3
0
    def setUser(self, u):
        self.user = u
        screenname = u['screen_name']
        self.image.setUrl(u['profile_image_url'])
        self.upperText.setHTML(
            '''%s<br/>%s''' %
            (u['name'],
             utils.screennameToTwitterLink(screenname, '@' + screenname)))
        
        friends = utils.splitthousands(u['friends_count'])
        followers = utils.splitthousands(u['followers_count'])
        tweets = utils.splitthousands(u['statuses_count'])
        location = u['location'] or 'unknown'
        self.lowerText.setHTML(
            '''Friends:&nbsp;%s<br/>
               Followers:&nbsp;%s<br/>
               Tweets:&nbsp;%s<br/>
               Location:&nbsp;%s<br/>
               Twitter id:&nbsp;%s<br/>
               Private:&nbsp;%s''' %
            (utils.screennameToTwitterFriendsLink(screenname, friends),
             utils.screennameToTwitterFollowersLink(screenname, followers),
             utils.screennameToTwitterLink(screenname, tweets),
             location, utils.splitthousands(u['id']), u['protected']))

        if self.followButton:
            self.remove(self.followButton)
            self.followButton = None
            
        following = u.get('following')
        if following is not None:
            if self.topPanel.loginPanel.screenname == screenname:
                # OK, I admit, this is ugly.
                self.followButton = Label("That's you!",
                                          StyleName='follow-button')
            else:
                if following:
                    text = _unfollowText
                else:
                    text = _followText
                self.followButton = Button(text, self,
                                           StyleName='follow-button')
            self.add(self.followButton)
示例#4
0
文件: banner.py 项目: jdunck/Tickery
 def _showCount(self, n):
     if isinstance(n, int):
         n = utils.splitthousands(n)
     self.countLabel.setHTML('Tracking %s users' % n)
示例#5
0
    def __init__(self, statusSummary, sender):
        VerticalPanel.__init__(self, Spacing=10,
                               StyleName='userlist-error-box')
        self.add(HTML("We're currently working on users you mentioned",
                      StyleName='userlist-error-title'))

        self.add(HTML(
            """<p>Below is a summary of work already in progress, or
        queued, which must complete before we can run your query. Please
        note that Tickery is subject to Twitter's API rate limiting and
        general network latency, so you may need to be patient. We'll get
        there!</p>

        <p><a href=\"%s\">Here's a link</a> to this results page so you can
        come back to see how we're doing.  You can also click %r again to
        see updated progress.</p>""" %
            (sender.resultsLink(), go.goButtonText),
            StyleName='userlist-error-text'))

        nRows = 0

        underway = statusSummary['underway']
        nUnderway = len(underway)
        queued = statusSummary['queued']
        nQueued = len(queued)

        nCols = 4
        width = 200

        if nUnderway:
            nRows += nUnderway + 1
        if nQueued:
            nRows += nQueued + 1

        g = Grid(nRows, nCols, StyleName='users')
        g.setCellPadding(2)
        cellFormatter = g.getCellFormatter()
        row = 0

        if nUnderway:
            g.setHTML(row, 0, 'Users currently being processed&nbsp;')
            cellFormatter.setStyleName(row, 0, 'title-lhs')
            g.setText(row, 1, 'Name')
            cellFormatter.setStyleName(row, 1, 'title')
            g.setText(row, 2, 'Friends')
            cellFormatter.setStyleName(row, 2, 'title')
            g.setText(row, 3, '% done')
            cellFormatter.setStyleName(row, 3, 'title')
            cellFormatter.setWidth(row, 3, width)
            row += 1

            for u, nFriends, done in underway:
                cellFormatter.setStyleName(row, 0, 'blank')
                n = utils.splitthousands(nFriends)
                g.setHTML(row, 1, utils.screennameToTwitterLink(u))
                g.setHTML(row, 2, utils.screennameToTwitterFriendsLink(u, n))
                cellFormatter.setHorizontalAlignment(row, 2, 'right')

                pct = '%d' % int(done * 100.0)
                left = Label(pct, StyleName='done', Width=int(done * width))
                g.setWidget(row, 3, left)

                row += 1

        if nQueued:
            g.setHTML(row, 0, 'Users queued for processing&nbsp;')
            cellFormatter.setStyleName(row, 0, 'title-lhs')
            g.setText(row, 1, 'Name')
            cellFormatter.setStyleName(row, 1, 'title')
            g.setText(row, 2, 'Friends')
            cellFormatter.setStyleName(row, 2, 'title')
            g.setText(row, 3, 'Queue position')
            cellFormatter.setStyleName(row, 3, 'title')
            row += 1

            for u, nFriends, pos in queued:
                cellFormatter.setStyleName(row, 0, 'blank')
                n = utils.splitthousands(nFriends)
                g.setHTML(row, 1, utils.screennameToTwitterLink(u))
                g.setHTML(row, 2, utils.screennameToTwitterFriendsLink(u, n))
                cellFormatter.setHorizontalAlignment(row, 2, 'right')
                g.setText(row, 3, pos)
                cellFormatter.setHorizontalAlignment(row, 3, 'right')
                row += 1

        self.add(g)