twitwi 0.20.0__py3-none-any.whl → 0.21.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,156 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: twitwi
3
- Version: 0.20.0
4
- Summary: A collection of Twitter-related helper functions for python.
5
- Home-page: http://github.com/medialab/twitwi
6
- Author: Béatrice Mazoyer, Guillaume Plique, Benjamin Ooghe-Tabanou
7
- Author-email: guillaume.plique@sciencespo.fr
8
- License: MIT
9
- Keywords: twitter
10
- Requires-Python: >=3.4
11
- Description-Content-Type: text/markdown
12
- License-File: LICENSE.txt
13
- Requires-Dist: pytz>=2019.3
14
- Requires-Dist: ural>=0.31.1
15
- Dynamic: author
16
- Dynamic: author-email
17
- Dynamic: description
18
- Dynamic: description-content-type
19
- Dynamic: home-page
20
- Dynamic: keywords
21
- Dynamic: license
22
- Dynamic: license-file
23
- Dynamic: requires-dist
24
- Dynamic: requires-python
25
- Dynamic: summary
26
-
27
- [![Build Status](https://github.com/medialab/twitwi/workflows/Tests/badge.svg)](https://github.com/medialab/twitwi/actions)
28
-
29
- # Twitwi
30
-
31
- A collection of Twitter-related helper functions for python.
32
-
33
- ## Installation
34
-
35
- You can install `twitwi` with pip with the following command:
36
-
37
- ```
38
- pip install twitwi
39
- ```
40
-
41
- ## Usage
42
-
43
- *Normalization functions*
44
-
45
- * [normalize_tweets_payload_v2](#normalize_tweets_payload_v2)
46
-
47
- *Formatting functions*
48
-
49
- * [transform_tweet_into_csv_dict](#transform_tweet_into_csv_dict)
50
- * [transform_user_into_csv_dict](#transform_user_into_csv_dict)
51
- * [format_tweet_as_csv_row](#format_tweet_as_csv_row)
52
-
53
- *Useful constants (under twitwi.constants)*
54
-
55
- * [TWEET_FIELDS](#tweet_fields)
56
- * [USER_FIELDS](#user_fields)
57
-
58
- ### normalize_tweets_payload_v2
59
-
60
- Function taking an entire tweets payload from the v2 API and returning a list of the contained tweets normalized and structured in a way that makes further analysis of the data convenient.
61
-
62
- ```python
63
- from twitwi import normalize_tweets_payload_v2
64
-
65
- # Normalizing an entire tweets payload to extract a list of tweets
66
- normalize_tweets_payload_v2(payload)
67
-
68
- # Normalizing an entire tweets payload to extract a list of tweets
69
- # as well as the referenced tweets (quoted, retweeted, etc.)
70
- normalize_tweets_payload_v2(payload, extract_referenced_tweets=True)
71
-
72
- # Converting found dates to a chosen timezone
73
- from pytz import timezone
74
- paris_tz = timezone('Europe/Paris')
75
-
76
- normalize_tweets_payload_v2(payload, locale=paris_tz)
77
- ```
78
-
79
- *Arguments*
80
-
81
- * **payload** *(dict)*: tweets payload coming from Twitter API v2.
82
- * **locale** *(pytz.timezone, optional)*: timezone used to convert dates. If not given, will default to UTC.
83
- * **extract_referenced_tweets** *(bool, optional)*: whether to keep referenced tweets (retweeted, quoted etc.) in the output. Defaults to `False`.
84
- * **collection_source** *(string, optional): An optional information to add to the tweets to indicate whence you collected them.
85
-
86
- ### transform_tweet_into_csv_dict
87
-
88
- Function transforming (i.e. mutating, so beware) a given normalized tweet into a suitable dict able to be written by a `csv.DictWriter` as a row.
89
-
90
- ```python
91
- from twitwi import transform_tweet_into_csv_dict
92
-
93
- # The function returns nothing, `normalized_tweet` has been mutated
94
- transform_tweet_into_csv_dict(normalized_tweet)
95
- ```
96
-
97
- ### transform_user_into_csv_dict
98
-
99
- Function transforming (i.e. mutating, so beware) a given normalized Twitter user into a suitable dict able to be written by a `csv.DictWriter` as a row.
100
-
101
- ```python
102
- from twitwi import transform_user_into_csv_dict
103
-
104
- # The function returns nothing, `normalized_user` has been mutated
105
- transform_user_into_csv_dict(normalized_user)
106
- ```
107
-
108
- ### format_tweet_as_csv_row
109
-
110
- Function formatting the given normalized tweet as a list able to be written by a `csv.writer` as a row.
111
-
112
- ```python
113
- from twitwi import format_tweet_as_csv_row
114
-
115
- row = format_tweet_as_csv_row(normalized_tweet)
116
- ```
117
-
118
- ### format_user_as_csv_row
119
-
120
- Function formatting the given normalized Twitter user as a list able to be written by a `csv.writer` as a row.
121
-
122
- ```python
123
- from twitwi import format_user_as_csv_row
124
-
125
- row = format_user_as_csv_row(normalized_user)
126
- ```
127
-
128
- ### TWEET_FIELDS
129
-
130
- List of tweet field names. Useful to declare headers with csv writers:
131
-
132
- ```python
133
- from twitwi.constants import TWEET_FIELDS
134
-
135
- # Using csv.writer
136
- w = csv.writer(f)
137
- w.writerow(TWEET_FIELDS)
138
-
139
- # Using csv.DictWriter
140
- w = csv.DictWriter(f, fieldnames=TWEET_FIELDS)
141
- w.writeheader()
142
- ```
143
-
144
- ### USER_FIELDS
145
-
146
- ```python
147
- from twitwi.constants import USER_FIELDS
148
-
149
- # Using csv.writer
150
- w = csv.writer(f)
151
- w.writerow(USER_FIELDS)
152
-
153
- # Using csv.DictWriter
154
- w = csv.DictWriter(f, fieldnames=USER_FIELDS)
155
- w.writeheader()
156
- ```
@@ -1,13 +0,0 @@
1
- twitwi/__init__.py,sha256=sAiVmg5YzZXFHUlCjm7oAccGoUZP0j19oyO37YGol-o,705
2
- twitwi/anonymizers.py,sha256=Dt72fdAJ4RzAxj-ZRmCVUNNWstlgvlJUNmUk520COOI,1594
3
- twitwi/constants.py,sha256=3kuQk_dijOJUKkSqBp7N4sHHNoDeAJWOQSDcnh7wSrg,16409
4
- twitwi/exceptions.py,sha256=kMHoWs57mpOzQGcGw4B3izCFVFzW5WIN1wgTbrP0Z2w,467
5
- twitwi/formatters.py,sha256=rK4IBBH-0PMRxQdDZ5szHKBk-J-AzefN8Wdj79L7YiY,3111
6
- twitwi/normalizers.py,sha256=L4YcQZudizP7gdHQmhwafT6o39uGNk3cxtOcA9U7OKE,27694
7
- twitwi/utils.py,sha256=iBxlCKjwPOz3RKIa8I_vs7d1miRi-eMXMpobKC5apZI,2349
8
- twitwi-0.20.0.dist-info/licenses/LICENSE.txt,sha256=Ddg_PcGnl0qd2167o2dheCjE_rCZJOoBxjJnJhhOpX4,1099
9
- twitwi-0.20.0.dist-info/METADATA,sha256=dVu4IykGtQyVd8-DCFBe3cXzOyd3jKcprEiy-38Jsvo,4360
10
- twitwi-0.20.0.dist-info/WHEEL,sha256=1tXe9gY0PYatrMPMDd6jXqjfpz_B-Wqm32CPfRC58XU,91
11
- twitwi-0.20.0.dist-info/top_level.txt,sha256=kellKVCFa_xo69jlXUtZXY2RYDd9ywdBe_-_iYK4W74,7
12
- twitwi-0.20.0.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
13
- twitwi-0.20.0.dist-info/RECORD,,