From 59ad210c71397fadc63ec27968597a4e9b5b4a52 Mon Sep 17 00:00:00 2001 From: Moritz Kiefer Date: Fri, 3 May 2013 12:10:24 +0200 Subject: [PATCH] Rename getToken() to get_token() --- diaspy/client.py | 8 ++++---- diaspy/connection.py | 4 ++-- diaspy/models.py | 12 ++++++------ diaspy/streams.py | 10 +++++----- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/diaspy/client.py b/diaspy/client.py index 1a43689..4e2cc0d 100644 --- a/diaspy/client.py +++ b/diaspy/client.py @@ -133,7 +133,7 @@ class Client: :type aspect_id: str """ - data = {'authenticity_token': self.connection.getToken(), + data = {'authenticity_token': self.connection.get_token(), 'aspect_id': aspect_id, 'person_id': user_id} @@ -158,7 +158,7 @@ class Client: :type aspect_id: str """ - data = {'authenticity_token': self.connection.getToken(), + data = {'authenticity_token': self.connection.get_token(), 'aspect_id': aspect_id, 'person_id': user_id} @@ -173,7 +173,7 @@ class Client: def remove_aspect(self, aspect_id): """ This function adds a new aspect. """ - data = {'authenticity_token': self.connection.getToken()} + data = {'authenticity_token': self.connection.get_token()} r = self.connection.delete('aspects/{}'.format(aspect_id), data=data) @@ -195,7 +195,7 @@ class Client: 'conversation[subject]': subject, 'conversation[text]': text, 'utf8': '✓', - 'authenticity_token': self.connection.getToken()} + 'authenticity_token': self.connection.get_token()} r = self.connection.post('conversations/', data=data, diff --git a/diaspy/connection.py b/diaspy/connection.py index af978d6..772e95a 100644 --- a/diaspy/connection.py +++ b/diaspy/connection.py @@ -92,7 +92,7 @@ class Connection(): self.username, self.password = username, password self.login_data = {'user[username]': self.username, 'user[password]': self.password, - 'authenticity_token': self.getToken()} + 'authenticity_token': self.get_token()} def _login(self): """Handles actual login request. @@ -127,7 +127,7 @@ class Connection(): userdata = json.loads(self._userinfo_regex.search(request.text).group(1)) return userdata - def getToken(self): + def get_token(self): """This function returns a token needed for authentication in most cases. :returns: string -- token used to authenticate diff --git a/diaspy/models.py b/diaspy/models.py index 66624f3..b7e7d76 100644 --- a/diaspy/models.py +++ b/diaspy/models.py @@ -32,7 +32,7 @@ class Post: :returns: dict -- json formatted like object. """ - data = {'authenticity_token': self._connection.getToken()} + data = {'authenticity_token': self._connection.get_token()} r = self._connection.post('posts/{0}/likes'.format(self.post_id), data=data, @@ -47,7 +47,7 @@ class Post: def delete_like(self): """This function removes a like from a post """ - data = {'authenticity_token': self._connection.getToken()} + data = {'authenticity_token': self._connection.get_token()} post_data = self.get_data() @@ -68,7 +68,7 @@ class Post: post_data = self.get_data() data = {'root_guid': post_data['guid'], - 'authenticity_token': self._connection.getToken()} + 'authenticity_token': self._connection.get_token()} r = self._connection.post('reshares', data=data, @@ -88,7 +88,7 @@ class Post: """ data = {'text': text, - 'authenticity_token': self._connection.getToken()} + 'authenticity_token': self._connection.get_token()} r = self._connection.post('posts/{0}/comments'.format(self.post_id), data=data, @@ -107,7 +107,7 @@ class Post: :type comment_id: str """ - data = {'authenticity_token': self._connection.getToken()} + data = {'authenticity_token': self._connection.get_token()} r = self._connection.delete('posts/{0}/comments/{1}' .format(self.post_id, @@ -122,7 +122,7 @@ class Post: def delete(self): """ This function deletes this post """ - data = {'authenticity_token': self._connection.getToken()} + data = {'authenticity_token': self._connection.get_token()} r = self._connection.delete('posts/{0}'.format(self.post_id), data=data, headers={'accept': 'application/json'}) diff --git a/diaspy/streams.py b/diaspy/streams.py index 872465f..a242f08 100644 --- a/diaspy/streams.py +++ b/diaspy/streams.py @@ -142,7 +142,7 @@ class Stream(Generic): data=json.dumps(data), headers={'content-type': 'application/json', 'accept': 'application/json', - 'x-csrf-token': self._connection.getToken()}) + 'x-csrf-token': self._connection.get_token()}) if request.status_code != 201: raise Exception('{0}: Post could not be posted.'.format( request.status_code)) @@ -167,7 +167,7 @@ class Stream(Generic): data = open(filename, 'rb') headers = {'content-type': 'application/octet-stream', - 'x-csrf-token': self._connection.getToken(), + 'x-csrf-token': self._connection.get_token(), 'x-file-name': filename} request = self._connection.post('photos', params=params, data=data, headers=headers) data.close() @@ -220,7 +220,7 @@ class Aspects(Generic): def add(self, aspect_name, visible=0): """This function adds a new aspect. """ - data = {'authenticity_token': self._connection.getToken(), + data = {'authenticity_token': self._connection.get_token(), 'aspect[name]': aspect_name, 'aspect[contacts_visible]': visible} @@ -266,11 +266,11 @@ class FollowedTags(Generic): :type tag_name: str """ data = {'name':tag_name, - 'authenticity_token':self._connection.getToken(), + 'authenticity_token':self._connection.get_token(), } headers={'content-type': 'application/json', - 'x-csrf-token': self._connection.getToken(), + 'x-csrf-token': self._connection.get_token(), 'accept': 'application/json'} request = self._connection.post('tag_followings', data=json.dumps(data), headers=headers) -- 2.25.1