



'''simple docstring'''





import csv

import tweepy

# Twitter API credentials
_lowerCAmelCase      						=	''''''
_lowerCAmelCase      						=	''''''
_lowerCAmelCase      						=	''''''
_lowerCAmelCase      						=	''''''
def    _SCREAMING_SNAKE_CASE  (       UpperCamelCase			):



    """simple docstring"""





    lowerCAmelCase__ :  Optional[Any]							      =					tweepy.OAuthHandler(UpperCamelCase							,    UpperCamelCase			)
    auth.set_access_token(UpperCamelCase							,    UpperCamelCase			)
    lowerCAmelCase__ :  Tuple							      =					tweepy.API(UpperCamelCase			)

    # initialize a list to hold all the tweepy Tweets
    lowerCAmelCase__ :  Optional[int]							      =					[]

    # make initial request for most recent tweets (200 is the maximum allowed count)
    lowerCAmelCase__ :  Any							      =					api.user_timeline(screen_name=UpperCamelCase							,    count=200			)

    # save most recent tweets
    alltweets.extend(UpperCamelCase			)

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

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

        # all subsequent requests use the max_id param to prevent duplicates
        lowerCAmelCase__ :  Optional[Any]							      =					api.user_timeline(
            screen_name=UpperCamelCase							,    count=200							,    max_id=UpperCamelCase			)

        # save most recent tweets
        alltweets.extend(UpperCamelCase			)

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

        print(f"""...{len(UpperCamelCase			)} tweets downloaded so far"""			)

    # transform the tweepy tweets into a 2D array that will populate the csv
    lowerCAmelCase__ :  str							      =					[[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__ :  List[str]							      =					csv.writer(UpperCamelCase			)
        writer.writerow(["""id""", """created_at""", """text"""]			)
        writer.writerows(UpperCamelCase			)


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







'''simple docstring'''





def    _SCREAMING_SNAKE_CASE  (       UpperCamelCase			):



    """simple docstring"""





    lowerCAmelCase__ :  Tuple							      =					abs(UpperCamelCase			)
    lowerCAmelCase__ :  List[Any]							      =					0
    while n > 0:
        res += n % 10
        n //= 10
    return res
def    _SCREAMING_SNAKE_CASE  (       UpperCamelCase			):



    """simple docstring"""





    lowerCAmelCase__ :  Union[str, Any]							      =					abs(UpperCamelCase			)
    return n if n < 10 else n % 10 + sum_of_digits(n // 10			)
def    _SCREAMING_SNAKE_CASE  (       UpperCamelCase			):



    """simple docstring"""





    return sum(int(UpperCamelCase			) for c in str(abs(UpperCamelCase			)			)			)
def    _SCREAMING_SNAKE_CASE  (       ):



    """simple docstring"""





    from collections.abc import Callable
    from timeit import timeit

    def benchmark_a_function(UpperCamelCase							,    UpperCamelCase			) -> None:
        lowerCAmelCase__ :  str							      =					f"""{func.__name__}({value})"""
        lowerCAmelCase__ :  str							      =					timeit(f"""__main__.{call}"""							,    setup="""import __main__"""			)
        print(f"""{call:56} = {func(UpperCamelCase			)} -- {timing:.4f} seconds"""			)

    for value in (262144, 1125899906842624, 1267650600228229401496703205376):
        for func in (sum_of_digits, sum_of_digits_recursion, sum_of_digits_compact):
            benchmark_a_function(UpperCamelCase							,    UpperCamelCase			)
        print()


if __name__ == "__main__":
 import doctest

 doctest.testmod()
 benchmark()


