



import csv

import tweepy

# Twitter API credentials
UpperCAmelCase_									=							""
UpperCAmelCase_									=							""
UpperCAmelCase_									=							""
UpperCAmelCase_									=							""
def 							UpperCAmelCase__		(				_SCREAMING_SNAKE_CASE   :	str				)->None:
      # authorize twitter, initialize tweepy
      _lowerCAmelCase 			=  tweepy.OAuthHandler(_SCREAMING_SNAKE_CASE     ,				_SCREAMING_SNAKE_CASE				)
      auth.set_access_token(_SCREAMING_SNAKE_CASE     ,				_SCREAMING_SNAKE_CASE				)
      _lowerCAmelCase 			=  tweepy.API(_SCREAMING_SNAKE_CASE				)

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

      # make initial request for most recent tweets (200 is the maximum allowed count)
      _lowerCAmelCase 			=  api.user_timeline(screen_name=_SCREAMING_SNAKE_CASE     ,				count=2_0_0				)

      # save most recent tweets
      alltweets.extend(_SCREAMING_SNAKE_CASE				)

      # save the id of the oldest tweet less one
      _lowerCAmelCase 			=  alltweets[-1].id - 1

      # keep grabbing tweets until there are no tweets left to grab
      while len(_SCREAMING_SNAKE_CASE				) > 0:
            print(f'''getting tweets before {oldest}'''				)

            # all subsequent requests use the max_id param to prevent duplicates
            _lowerCAmelCase 			=  api.user_timeline(
                screen_name=_SCREAMING_SNAKE_CASE     ,				count=2_0_0     ,				max_id=_SCREAMING_SNAKE_CASE				)

            # save most recent tweets
            alltweets.extend(_SCREAMING_SNAKE_CASE				)

            # update the id of the oldest tweet less one
            _lowerCAmelCase 			=  alltweets[-1].id - 1

            print(f'''...{len(_SCREAMING_SNAKE_CASE				)} tweets downloaded so far'''				)

      # transform the tweepy tweets into a 2D array that will populate the csv
      _lowerCAmelCase 			=  [[tweet.id_str, tweet.created_at, tweet.text] for tweet in alltweets]

      # write the csv
      with open(f'''new_{screen_name}_tweets.csv'''     ,				'''w'''				) as f:
            _lowerCAmelCase 			=  csv.writer(_SCREAMING_SNAKE_CASE				)
            writer.writerow(['''id''', '''created_at''', '''text''']				)
            writer.writerows(_SCREAMING_SNAKE_CASE				)


if __name__ == "__main__":
    # pass in the username of the account you want to download
    get_all_tweets("FirePing32")




from tempfile import TemporaryDirectory
from unittest import TestCase
from unittest.mock import MagicMock, patch

from transformers import AutoModel, TFAutoModel
from transformers.onnx import FeaturesManager
from transformers.testing_utils import SMALL_MODEL_IDENTIFIER, require_tf, require_torch





@require_torch
@require_tf
class 		UpperCAmelCase						(						snake_case_				):





   def 	__lowerCAmelCase							(	self			):
         _lowerCAmelCase 			=  SMALL_MODEL_IDENTIFIER
         _lowerCAmelCase 			=  '''pt'''
         _lowerCAmelCase 			=  '''tf'''





   def 	__lowerCAmelCase							(	self       ,     _lowerCAmelCase			):
         _lowerCAmelCase 			=  AutoModel.from_pretrained(self.test_model			)
         model_pt.save_pretrained(_lowerCAmelCase			)





   def 	__lowerCAmelCase							(	self       ,     _lowerCAmelCase			):
         _lowerCAmelCase 			=  TFAutoModel.from_pretrained(self.test_model       ,     from_pt=_lowerCAmelCase			)
         model_tf.save_pretrained(_lowerCAmelCase			)





   def 	__lowerCAmelCase							(	self			):
         _lowerCAmelCase 			=  '''mock_framework'''

         # Framework provided - return whatever the user provides
         _lowerCAmelCase 			=  FeaturesManager.determine_framework(self.test_model       ,     _lowerCAmelCase			)
         self.assertEqual(_lowerCAmelCase       ,     _lowerCAmelCase			)

         # Local checkpoint and framework provided - return provided framework
         # PyTorch checkpoint
         with TemporaryDirectory() as local_pt_ckpt:
               self._setup_pt_ckpt(_lowerCAmelCase			)
               _lowerCAmelCase 			=  FeaturesManager.determine_framework(_lowerCAmelCase       ,     _lowerCAmelCase			)
               self.assertEqual(_lowerCAmelCase       ,     _lowerCAmelCase			)

         # TensorFlow checkpoint
         with TemporaryDirectory() as local_tf_ckpt:
               self._setup_tf_ckpt(_lowerCAmelCase			)
               _lowerCAmelCase 			=  FeaturesManager.determine_framework(_lowerCAmelCase       ,     _lowerCAmelCase			)
               self.assertEqual(_lowerCAmelCase       ,     _lowerCAmelCase			)





   def 	__lowerCAmelCase							(	self			):
         # PyTorch checkpoint
         with TemporaryDirectory() as local_pt_ckpt:
               self._setup_pt_ckpt(_lowerCAmelCase			)
               _lowerCAmelCase 			=  FeaturesManager.determine_framework(_lowerCAmelCase			)
               self.assertEqual(_lowerCAmelCase       ,     self.framework_pt			)

         # TensorFlow checkpoint
         with TemporaryDirectory() as local_tf_ckpt:
               self._setup_tf_ckpt(_lowerCAmelCase			)
               _lowerCAmelCase 			=  FeaturesManager.determine_framework(_lowerCAmelCase			)
               self.assertEqual(_lowerCAmelCase       ,     self.framework_tf			)

         # Invalid local checkpoint
         with TemporaryDirectory() as local_invalid_ckpt:
               with self.assertRaises(_lowerCAmelCase			):
                     _lowerCAmelCase 			=  FeaturesManager.determine_framework(_lowerCAmelCase			)





   def 	__lowerCAmelCase							(	self			):
         _lowerCAmelCase 			=  MagicMock(return_value=_lowerCAmelCase			)
         with patch('''transformers.onnx.features.is_tf_available'''       ,     _lowerCAmelCase			):
               _lowerCAmelCase 			=  FeaturesManager.determine_framework(self.test_model			)
               self.assertEqual(_lowerCAmelCase       ,     self.framework_pt			)

         # PyTorch not in environment -> use TensorFlow
         _lowerCAmelCase 			=  MagicMock(return_value=_lowerCAmelCase			)
         with patch('''transformers.onnx.features.is_torch_available'''       ,     _lowerCAmelCase			):
               _lowerCAmelCase 			=  FeaturesManager.determine_framework(self.test_model			)
               self.assertEqual(_lowerCAmelCase       ,     self.framework_tf			)

         # Both in environment -> use PyTorch
         _lowerCAmelCase 			=  MagicMock(return_value=_lowerCAmelCase			)
         _lowerCAmelCase 			=  MagicMock(return_value=_lowerCAmelCase			)
         with patch('''transformers.onnx.features.is_tf_available'''       ,     _lowerCAmelCase			), patch(
             '''transformers.onnx.features.is_torch_available'''       ,     _lowerCAmelCase			):
               _lowerCAmelCase 			=  FeaturesManager.determine_framework(self.test_model			)
               self.assertEqual(_lowerCAmelCase       ,     self.framework_pt			)

         # Both not in environment -> raise error
         _lowerCAmelCase 			=  MagicMock(return_value=_lowerCAmelCase			)
         _lowerCAmelCase 			=  MagicMock(return_value=_lowerCAmelCase			)
         with patch('''transformers.onnx.features.is_tf_available'''       ,     _lowerCAmelCase			), patch(
             '''transformers.onnx.features.is_torch_available'''       ,     _lowerCAmelCase			):
               with self.assertRaises(_lowerCAmelCase			):
                     _lowerCAmelCase 			=  FeaturesManager.determine_framework(self.test_model			)