Returns the minimal tweet ID of the current response

        :returns: minimal tweet identification number
        :raises: TwitterSearchException
189949
def get_minimal_id(self):
        

        if not self.__response:
            raise TwitterSearchException(1013)

        return min(
            self.__response['content']['statuses'] if self.__order_is_search
            else self.__response['content'],
            key=lambda i: i['id']
            )['id'] - 1
1013640
def get_current_context_id():
    
    global get_current_context_id
    if greenlet is not None:
        if stackless is None:
            get_current_context_id = greenlet.getcurrent
            return greenlet.getcurrent()
        return greenlet.getcurrent(), stackless.getcurrent()
    elif stackless is not None:
        get_current_context_id = stackless.getcurrent
        return stackless.getcurrent()
    get_current_context_id = _thread.get_ident
    return _thread.get_ident()
882258
def next(self):
        
        smallest = None
        for key in self.queue.keys():
            if self.queue[key]['status'] == 'queued':
                if smallest is None or key < smallest:
                    smallest = key
        return smallest
1099300
def _set_least_batch_id(self, txn_signature):
        

        batch = self._batches_by_txn_id[txn_signature]

        least_index = self._index_of_batch(
            self._batches_by_id[self._least_batch_id_wo_results].batch)

        current_index = self._index_of_batch(batch)
        all_prior = False

        if current_index <= least_index:
            return
            # Test to see if all batches from the least_batch to
            # the prior batch to the current batch have results.
        if all(
                all(t.header_signature in self._txn_results
                    for t in b.transactions)
                for b in self._batches[least_index:current_index]):
            all_prior = True
        if not all_prior:
            return
        possible_least = self._batches[current_index].header_signature
        # Find the first batch from the current batch on, that doesn't have
        # all results.
        for b in self._batches[current_index:]:
            if not all(t.header_signature in self._txn_results
                       for t in b.transactions):
                possible_least = b.header_signature
                break
        self._least_batch_id_wo_results = possible_least
1373076
def version_id(self):
        
        return hashlib.sha1('{0}__{1}'.format(
            self.id, self.updated).encode('utf-8')).hexdigest()
292617
def firstId(self):
        
        if self._first is False:
            # Request the next urn
            self._first = self.getFirstUrn()
        return self._first
150791
def get_twitter_id(self, cache=True):
        
        if not (cache and ('twitter' in self.cache)):
            response = self.get_attribute('twitter')
            self.cache['twitter'] = response['artist'].get('twitter')
        return self.cache['twitter']
1255351
def doc_id(self):
        
        if self.id:
            return '%s_%s' % (self.doc_type, self.id.lower())
        return self._hashed_key
732509
def get_all_docs(self, screen_name):
        
        def _getNewTweets(api, screen_name,count=200, oldest=None, waitTime=60):
            """
                MEthod that recovers the new tweets or waits until the number of remaining calls has been freed.

                :param api:     A valid and connected api.
                :param screen_name: screen_name of the user to monitor.
                :param count:   Number of tweets to grab per iteration.
                :param oldes:  Oldest tweet to grab in this iteration.
                :param waitTime:    Number of seconds to wait between tries.

                :return:  List of new_tweets
            """
            # Verifying the limits of the API
            #self._rate_limit_status(api=api, mode="get_all_docs")

            waiting = True
            while waiting == True:
                try:
                    if oldest != None:
                        # We have to update the oldest id
                        new_tweets = api.user_timeline(screen_name=screen_name, count=count, max_id=oldest)
                    else:
                        new_tweets = api.user_timeline(screen_name=screen_name, count=count)
                    waiting = False
                    #save most recent tweets

                except Exception as e:
                    # Error... We will have to wait
                    #waiting = True
                    print str(e)
                    #print(traceback.format_exc())
                    print "No more queries remaining, sleeping for " + str(waitTime) +" seconds..."
                    time.sleep(waitTime)

            return new_tweets

        # Connecting to the API
        api = self._connectToAPI()

        #initialize a list to hold all the tweepy Tweets
        alltweets = []

        #make initial request for most recent tweets (200 is the maximum allowed count)
        """waiting = True
        while waiting == True:
            try:
                new_tweets = api.user_timeline(screen_name = screen_name,count=200)
                waiting = False
            except:
                # Error... We will have to wait
                waiting = True
                time.sleep(waitTime)  """
        new_tweets = _getNewTweets(api, screen_name)

        alltweets.extend(new_tweets)
        # Storing manually all the json representation for the tweets
        jTweets = []
        for n in new_tweets:
            jTweets.append(n._json)
        if len(alltweets) > 0:
            #save the id of the oldest tweet less one
            oldest = alltweets[-1].id - 1

            #keep grabbing tweets until there are no tweets left to grab
            while len(new_tweets) > 0:
                print "Getting tweets before %s" % (oldest)

                """ #all subsequent requests use the max_id param to prevent duplicates
                waiting = True
                while waiting == True:
                    try:
                        # We have to update the oldest id
                        new_tweets = api.user_timeline(screen_name = screen_name,count=200, max_id=oldest)
                        waiting = False
                        #save most recent tweets

                    except:
                        # Error... We will have to wait
                        waiting = True
                        print "No more queries remaining, sleeping for " + str(waitTime) +" seconds..."
                        time.sleep(waitTime)  """

                new_tweets = _getNewTweets(api, screen_name, oldest=oldest)

                # Extending the list of tweets
                alltweets.extend(new_tweets)

                #update the id of the oldest tweet less one
                oldest = alltweets[-1].id - 1
                print "... %s tweets downloaded so far" % (len(alltweets))
                # Storing manually all the json representation for the tweets
                for n in new_tweets:
                    jTweets.append(n._json)
        else:
            # Verifying the limits of the API
            print json.dumps(self._rate_limit_status(api=api, mode="get_all_docs"), indent =2)

        #transform the tweepy tweets into a 2D array that will populate the csv
        outtweets = []
        # This is how it is represented
        """
          "status": {
            "lang": "es",
            "favorited": false,
            "entities": {
              "symbols": [],
              "user_mentions": [],
              "hashtags": [],
              "urls": []
            },
            "contributors": null,
            "truncated": false,
            "text": "Podemos confirmar que Alpify, aunque acabe en ...fy no es una aplicaci\u00f3n nuestra. ;) \u00a1A aprovechar lo que queda de domingo!",
            "created_at": "Sun Aug 16 17:35:37 +0000 2015",
            "retweeted": true,
            "in_reply_to_status_id_str": null,
            "coordinates": null,
            "in_reply_to_user_id_str": null,
            "source": "<a href=\"http://twitter.com\" rel=\"nofollow\">Twitter Web Client</a>",
            "in_reply_to_status_id": null,
            "in_reply_to_screen_name": null,
            "id_str": "632968969662689280",
            "place": null,
            "retweet_count": 1,
            "geo": null,
            "id": 632968969662689280,
            "favorite_count": 0,
            "in_reply_to_user_id": null
          },
        """
        for tweet in jTweets:
            row =[]
            row.append(tweet["id_str"])
            row.append(tweet["created_at"])
            row.append(tweet["text"].encode("utf-8"))
            row.append(tweet["source"])
            row.append(tweet["coordinates"])
            row.append(tweet["retweet_count"])
            row.append(tweet["favorite_count"])
            row.append(tweet["lang"])
            row.append(tweet["place"])
            row.append(tweet["geo"])
            row.append(tweet["id"])
            row.append(screen_name)

            # URLS
            urls = []
            """
            [
                {
                  "url": "http://t.co/SGty7or6SQ",
                  "indices": [
                    30,
                    52
                  ],
                  "expanded_url": "http://github.com/i3visio/osrframework",
                  "display_url": "github.com/i3visio/osrfra\u2026"
                }
            ]
            """
            for u in tweet["entities"]["urls"]:
                urls.append(u["expanded_url"])
            # Creating the string value for the cell
            str_urls =""
            if len(urls) == 0:
                str_urls = "[N/A]"
            else:
                for i, u in enumerate(urls):
                    str_urls += u
                    # Appending a separator
                    if i+1 <> len(urls):
                        str_urls+= "|"
            row.append(str_urls.encode('utf-8'))

            # TODO: Extract Mentions
            mentions = []
            """ "user_mentions": [
              {
                "id": 66345537,
                "indices": [
                  0,
                  10
                ],
                "id_str": "66345537",
                "screen_name": "muchotomy",
                "name": "Tomy"
              },
            """
            for a in tweet["entities"]["user_mentions"]:
                mentions.append(a["screen_name"])
            # Creating the string value for the cell
            str_mentions =""
            if len(mentions) == 0:
                str_mentions = "[N/A]"
            else:
                for i, m in enumerate(mentions):
                    str_mentions += m
                    # Appending a separator
                    if i+1 <> len(mentions):
                        str_mentions+= "|"
            row.append(str_mentions.encode('utf-8'))

            # Appending the row to the output
            outtweets.append(row)

        # Writing the csv
        with open('%s_tweets.csv' % screen_name, 'wb') as f:
            writer = csv.writer(f)
            # Writing the headers
            writer.writerow([
                "_tweet_id",
                "_tweet_created_at",
                "_tweet_text",
                "_tweet_source",
                "_tweet_coordinates",
                "_tweet_retweet_count",
                "_tweet_favourite_count",
                "_tweet_lang",
                "i3visio_location",
                "_tweet_geo",
                "_twitter_id",
                "i3visio_alias",
                "i3visio_uri",
                "i3visio_alias_mentions",
            ])
            # Writing the rows
            #writer.writerows(outtweets)
            for o in outtweets:
                try:
                    writer.writerow(o)
                except:
                    print o

        return jTweets
198575
def minor(self):
        
        url = self._subfeed("minor")
        if "minor" in self.url or "major" in self.url:
            return self
        if self._minor is None:
            self._minor = self.__class__(url, pypump=self._pump)
        return self._minor
461831
def tweets_for_user(screen_name, limit=1e10):
    
    qu = Queue()
    p = Thread(target=_tweets_for_user, args=(qu, screen_name, limit))
    p.start()
    p.join(910)
    if p.is_alive():
        sys.stderr.write('no results after 15 minutes for %s. Aborting.' % screen_name)
        return []
    else:
        return qu.get()
791345
def tohu_id(self):
        
        myhash = hashlib.md5(str(id(self)).encode()).hexdigest()
        return myhash[:12]
609165
def get_tweet(self, id):
        
        try:
            return Tweet(self._client.get_status(id=id)._json)
        except TweepError as e:
            if e.api_code == TWITTER_TWEET_NOT_FOUND_ERROR:
                return None
            raise
154708
def to_id(self):
        
        return "%s%s%s%s%s" % (TraceId.VERSION, TraceId.DELIMITER,
                               format(self.start_time, 'x'),
                               TraceId.DELIMITER, self.__number)
314557
def _GetClientIdFromQueue(q):
  
  split = q.Split()
  if not split or len(split) < 2:
    return None

  # Normalize to lowercase.
  split = [s.lower() for s in split]

  str_client_id, tasks_marker = split

  if not str_client_id.startswith("c.") or tasks_marker != "tasks":
    return None

  # The "C." prefix should be uppercase.
  str_client_id = "C" + str_client_id[1:]

  return str_client_id
1265151
def search(self, q=None, **kw):
        
        if q is None:
            raise ValueError('No search query provided for `q` keyword.')
        return self.twitter.search.tweets(q=q, **kw)
557681
def get_message_id(self):
        """"""
        message_id = self.json_response.get("messageId", None)
        self.logger.info("%s\t%s" % (self.request_method, self.request_url))
        return message_id