aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLorenz Diener <[email protected]>2017-04-26 12:19:41 +0200
committerLorenz Diener <[email protected]>2017-04-26 12:19:41 +0200
commit7cfb17d6981c0814c3b5c38f3bc9712a73d1da03 (patch)
tree7531a5757dc02bdafab36b0f1c66ffe98e8e85e0
parent4a2f6d0fb90958aab54dab86666ed6034d0e1929 (diff)
downloadmastodon.py-7cfb17d6981c0814c3b5c38f3bc9712a73d1da03.tar.gz
Documentation and consistence changes
-rw-r--r--docs/index.rst91
-rw-r--r--mastodon/Mastodon.py9
2 files changed, 62 insertions, 38 deletions
diff --git a/docs/index.rst b/docs/index.rst
index cba55f3..bad52d2 100644
--- a/docs/index.rst
+++ b/docs/index.rst
@@ -109,24 +109,24 @@ Toot dicts
109 mastodon.toot("Hello from Python") 109 mastodon.toot("Hello from Python")
110 # Returns the following dictionary: 110 # Returns the following dictionary:
111 { 111 {
112 'sensitive': Denotes whether media attachments to the toot are marked sensitive 112 'sensitive': # Denotes whether media attachments to the toot are marked sensitive
113 'created_at': Creation time 113 'created_at': # Creation time
114 'mentions': A list of account dicts mentioned in the toot 114 'mentions': # A list of account dicts mentioned in the toot
115 'uri': Descriptor for the toot 115 'uri': # Descriptor for the toot
116 EG 'tag:mastodon.social,2016-11-25:objectId=<id>:objectType=Status' 116 # EG 'tag:mastodon.social,2016-11-25:objectId=<id>:objectType=Status'
117 'tags': A list of hashtag dicts used in the toot 117 'tags': # A list of hashtag dicts used in the toot
118 'in_reply_to_id': Numerical id of the toot this toot is in response to 118 'in_reply_to_id': # Numerical id of the toot this toot is in response to
119 'media_attachments': list of media dicts of attached files. Only present 119 'media_attachments': # list of media dicts of attached files. Only present
120 when there are attached files. 120 # when there are attached files.
121 'id': Numerical id of this toot 121 'id': # Numerical id of this toot
122 'reblogs_count': Number of reblogs 122 'reblogs_count': # Number of reblogs
123 'favourites_count': Number of favourites 123 'favourites_count': # Number of favourites
124 'reblog': Denotes whether the toot is a reblog 124 'reblog': # Denotes whether the toot is a reblog
125 'url': URL of the toot 125 'url': # URL of the toot
126 'content': Content of the toot, as HTML: '<p>Hello from Python</p>' 126 'content': # Content of the toot, as HTML: '<p>Hello from Python</p>'
127 'spoiler_text': Warning text that should be displayed before the toot content 127 'spoiler_text': # Warning text that should be displayed before the toot content
128 'favourited': Denotes whether the logged in user has favourited this toot 128 'favourited': # Denotes whether the logged in user has favourited this toot
129 'account': Account dict for the logged in account 129 'account': # Account dict for the logged in account
130 } 130 }
131 131
132Relationship dicts 132Relationship dicts
@@ -136,12 +136,12 @@ Relationship dicts
136 mastodon.account_follow(<numerical id>) 136 mastodon.account_follow(<numerical id>)
137 # Returns the following dictionary: 137 # Returns the following dictionary:
138 { 138 {
139 'followed_by': Boolean denoting whether they follow you back 139 'followed_by': # Boolean denoting whether they follow you back
140 'following': Boolean denoting whether you follow them 140 'following': # Boolean denoting whether you follow them
141 'id': Numerical id (same one as <numerical id>) 141 'id': # Numerical id (same one as <numerical id>)
142 'blocking': Boolean denoting whether you are blocking them 142 'blocking': # Boolean denoting whether you are blocking them
143 'muting': Boolean denoting whether you are muting them 143 'muting': # Boolean denoting whether you are muting them
144 'requested': Boolean denoting whether you have sent them a follow request 144 'requested': # Boolean denoting whether you have sent them a follow request
145 } 145 }
146 146
147Notification dicts 147Notification dicts
@@ -151,11 +151,11 @@ Notification dicts
151 mastodon.notifications()[0] 151 mastodon.notifications()[0]
152 # Returns the following dictionary: 152 # Returns the following dictionary:
153 { 153 {
154 'id': id of the notification. 154 'id': # id of the notification.
155 'type': "mention", "reblog", "favourite" or "follow". 155 'type': # "mention", "reblog", "favourite" or "follow".
156 'status': In case of "mention", the mentioning status. 156 'status': # In case of "mention", the mentioning status.
157 In case of reblog / favourite, the reblogged / favourited status. 157 # In case of reblog / favourite, the reblogged / favourited status.
158 'account': User dict of the user from whom the notification originates. 158 'account': # User dict of the user from whom the notification originates.
159 } 159 }
160 160
161Context dicts 161Context dicts
@@ -165,8 +165,8 @@ Context dicts
165 mastodon.status_context(<numerical id>) 165 mastodon.status_context(<numerical id>)
166 # Returns the following dictionary: 166 # Returns the following dictionary:
167 { 167 {
168 'descendants': A list of toot dicts 168 'descendants': # A list of toot dicts
169 'ancestors': A list of toot dicts 169 'ancestors': # A list of toot dicts
170 } 170 }
171 171
172Media dicts 172Media dicts
@@ -176,10 +176,10 @@ Media dicts
176 mastodon.media_post("image.jpg", "image/jpeg") 176 mastodon.media_post("image.jpg", "image/jpeg")
177 # Returns the following dictionary: 177 # Returns the following dictionary:
178 { 178 {
179 'text_url': The display text for the media (what shows up in toots) 179 'text_url': # The display text for the media (what shows up in toots)
180 'preview_url': The URL for the media preview 180 'preview_url': # The URL for the media preview
181 'type': Media type, EG 'image' 181 'type': # Media type, EG 'image'
182 'url': The URL for the media 182 'url': # The URL for the media
183 } 183 }
184 184
185App registration and user authentication 185App registration and user authentication
@@ -200,6 +200,7 @@ methods for this are provided.
200.. automethod:: Mastodon.create_app 200.. automethod:: Mastodon.create_app
201.. automethod:: Mastodon.__init__ 201.. automethod:: Mastodon.__init__
202.. automethod:: Mastodon.log_in 202.. automethod:: Mastodon.log_in
203.. automethod:: Mastodon.auth_request_url
203 204
204Reading data: Timelines 205Reading data: Timelines
205----------------------- 206-----------------------
@@ -237,9 +238,17 @@ their relationships.
237.. automethod:: Mastodon.account_statuses 238.. automethod:: Mastodon.account_statuses
238.. automethod:: Mastodon.account_following 239.. automethod:: Mastodon.account_following
239.. automethod:: Mastodon.account_followers 240.. automethod:: Mastodon.account_followers
241.. automethod:: Mastodon.follows
240.. automethod:: Mastodon.account_relationships 242.. automethod:: Mastodon.account_relationships
241.. automethod:: Mastodon.account_search 243.. automethod:: Mastodon.account_search
242 244
245Reading data: Searching
246-----------------------
247This function allows you to search for content.
248
249.. automethod:: Mastodon.search
250
251
243Reading data: Mutes and blocks 252Reading data: Mutes and blocks
244------------------------------ 253------------------------------
245These functions allow you to get information about accounts that are 254These functions allow you to get information about accounts that are
@@ -253,7 +262,7 @@ Reading data: Favourites
253This function allows you to get information about statuses favourited 262This function allows you to get information about statuses favourited
254by the authenticated user. 263by the authenticated user.
255 264
256.. authomethod:: Mastodon.favourites 265.. automethod:: Mastodon.favourites
257 266
258Reading data: Follow requests 267Reading data: Follow requests
259----------------------------- 268-----------------------------
@@ -302,7 +311,15 @@ to attach media to statuses.
302 311
303.. automethod:: Mastodon.media_post 312.. automethod:: Mastodon.media_post
304 313
314Streaming
315---------
316These functions allow access to the streaming API.
317
318.. automethod:: Mastodon.user_stream
319.. automethod:: Mastodon.public_stream
320.. automethod:: Mastodon.hashtag_stream
321
305 322
306.. _Mastodon: https://github.com/Gargron/mastodon 323.. _Mastodon: https://github.com/Gargron/mastodon
307.. _Mastodon flagship instance: http://mastodon.social/ 324.. _Mastodon flagship instance: http://mastodon.social/
308.. _Mastodon api docs: https://github.com/Gargron/mastodon/wiki/API 325.. _Mastodon api docs: https://github.com/Gargron/mastodon/wiki/API \ No newline at end of file
diff --git a/mastodon/Mastodon.py b/mastodon/Mastodon.py
index e670a7f..88daac8 100644
--- a/mastodon/Mastodon.py
+++ b/mastodon/Mastodon.py
@@ -133,19 +133,23 @@ class Mastodon:
133 133
134 134
135 def __get_token_expired(self): 135 def __get_token_expired(self):
136 """Internal helper for oauth code"""
136 if self._token_expired < datetime.datetime.now(): 137 if self._token_expired < datetime.datetime.now():
137 return True 138 return True
138 else: 139 else:
139 return False 140 return False
140 141
141 def __set_token_expired(self, value): 142 def __set_token_expired(self, value):
143 """Internal helper for oauth code"""
142 self._token_expired = datetime.datetime.now() + datetime.timedelta(seconds=value) 144 self._token_expired = datetime.datetime.now() + datetime.timedelta(seconds=value)
143 return 145 return
144 146
145 def __get_refresh_token(self): 147 def __get_refresh_token(self):
148 """Internal helper for oauth code"""
146 return self._refresh_token 149 return self._refresh_token
147 150
148 def __set_refresh_token(self, value): 151 def __set_refresh_token(self, value):
152 """Internal helper for oauth code"""
149 self._refresh_token = value 153 self._refresh_token = value
150 return 154 return
151 155
@@ -414,7 +418,7 @@ class Mastodon:
414 ### 418 ###
415 # Reading data: Searching 419 # Reading data: Searching
416 ### 420 ###
417 def content_search(self, q, resolve = False): 421 def search(self, q, resolve = False):
418 """ 422 """
419 Fetch matching hashtags, accounts and statuses. Will search federated 423 Fetch matching hashtags, accounts and statuses. Will search federated
420 instances if resolve is True. 424 instances if resolve is True.
@@ -676,6 +680,9 @@ class Mastodon:
676 media_file_description = (file_name, media_file, mime_type) 680 media_file_description = (file_name, media_file, mime_type)
677 return self.__api_request('POST', '/api/v1/media', files = {'file': media_file_description}) 681 return self.__api_request('POST', '/api/v1/media', files = {'file': media_file_description})
678 682
683 ###
684 # Streaming
685 ###
679 def user_stream(self, listener): 686 def user_stream(self, listener):
680 """ 687 """
681 Streams events that are relevant to the authorized user, i.e. home 688 Streams events that are relevant to the authorized user, i.e. home
Powered by cgit v1.2.3 (git 2.41.0)