"""
self._token_regex = re.compile(r'content="(.*?)"\s+name="csrf-token')
self.pod = pod
+ self.logged_in = False
self.session = requests.Session()
self._setlogindata(username, password)
headers={'accept': 'application/json'})
if r.status_code != 201: raise Exception('{0}: Login failed.'.format(r.status_code))
+ else: self.logged_in = True
def post(self, text, aspect_id='public', photos=None):
"""This function sends a post to an aspect
raise Exception('wrong status code: {0}'.format(r.status_code))
stream = r.json()
-
- posts = []
-
- for post in stream:
- posts.append(diaspy.models.Post(str(post['id']), self))
+ posts = [ diaspy.models.Post(str(post['id']), self) for post in stream ]
return posts
raise Exception('wrong status code: {0}'.format(r.status_code))
mentions = r.json()
-
- posts = []
-
- for post in mentions:
- posts.append(diaspy.models.Post(str(post['id']), self))
+ posts = [ diaspy.models.Post(str(post['id']), self) for post in mentions ]
return posts
raise Exception('wrong status code: {0}'.format(r.status_code))
tagged_posts = r.json()
-
- posts = []
-
- for post in tagged_posts:
- posts.append(diaspy.models.Post(str(post['id']), self))
+ posts = [ diaspy.models.Post(str(post['id']), self) for post in tagged_posts ]
return posts
raise Exception('wrong status code: {0}'.format(r.status_code))
mailbox = r.json()
-
- conversations = []
-
- for conversation in mailbox:
- conversations.append(diaspy.conversations.Conversation(str(conversation['conversation']['id']), self))
+ conversations = [ diaspy.conversations.Conversation(str(conversation['conversation']['id']), self) for conversation in mailbox ]
return conversations