コード例 #1
0
    def put(self, tweets):
        filtered_tweets = filter(lambda t: not tweet.RETWEETED_STATUS in t, tweets)
        normalized_tweets = map(lambda t: tweet.to_date(tweet.to_ascii(t)), filtered_tweets)

        if len(normalized_tweets) == 0:
            return

        try:
            self._tweet_coll.insert(normalized_tweets, continue_on_error = True)
        except DuplicateKeyError:
            pass # Ignored.
コード例 #2
0
    def on_success(self, data):
        t = tweet.to_date(data)

        if t[tweet.CREATED_AT] > self._search_to:
            self.flush()
            self.disconnect()
            return

        self._buffer.append(t)
        self._parent.update()

        if len(self._buffer) > CHUNK_SIZE:
            self.flush()