From: Marek Marecki <marekjm@taistelu.com> Date: Thu, 8 Aug 2013 16:23:42 +0000 (+0200) Subject: Err, it was kinda stupid to return anything about *deleted* stuff, X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=e7abf853bd293f4e622ea7726ec68e5f855b3fd7;p=diaspy.git Err, it was kinda stupid to return anything about *deleted* stuff, removed it --- diff --git a/diaspy/models.py b/diaspy/models.py index 0c5f4f2..1d0156f 100644 --- a/diaspy/models.py +++ b/diaspy/models.py @@ -1,17 +1,17 @@ #!/usr/bin/env python3 +"""This module is only imported in other diaspy modules and +MUST NOT import anything. +""" + + import json import re from diaspy import errors -"""This module is only imported in other diaspy modules and -MUST NOT import anything. -""" - - class Aspect(): """This class represents an aspect. @@ -316,20 +316,6 @@ class Post(): .format(request.status_code)) return request.json() - def delete_like(self): - """This function removes a like from a post - """ - data = {'authenticity_token': self._connection.get_token()} - - request = self._connection.delete('posts/{0}/likes/{1}' - .format(self.id, - self.data['interactions'] - ['likes'][0]['id']), - data=data) - if request.status_code != 204: - raise errors.PostError('{0}: Like could not be removed.' - .format(request.status_code)) - def reshare(self): """This function reshares a post """ @@ -360,6 +346,16 @@ class Post(): .format(request.status_code)) return request.json() + def delete(self): + """ This function deletes this post + """ + data = {'authenticity_token': repr(self._connection)} + request = self._connection.delete('posts/{0}'.format(self.id), + data=data, + headers={'accept': 'application/json'}) + if request.status_code != 204: + raise errors.PostError('{0}: Post could not be deleted'.format(request.status_code)) + def delete_comment(self, comment_id): """This function removes a comment from a post @@ -376,17 +372,20 @@ class Post(): if request.status_code != 204: raise errors.PostError('{0}: Comment could not be deleted' .format(request.status_code)) - return request.status_code - def delete(self): - """ This function deletes this post + def delete_like(self): + """This function removes a like from a post """ - data = {'authenticity_token': repr(self._connection)} - request = self._connection.delete('posts/{0}'.format(self.id), - data=data, - headers={'accept': 'application/json'}) + data = {'authenticity_token': self._connection.get_token()} + + request = self._connection.delete('posts/{0}/likes/{1}' + .format(self.id, + self.data['interactions'] + ['likes'][0]['id']), + data=data) if request.status_code != 204: - raise errors.PostError('{0}: Post could not be deleted'.format(request.status_code)) + raise errors.PostError('{0}: Like could not be removed.' + .format(request.status_code)) def author(self, key='name'): """Returns author of the post. diff --git a/logger.py b/logger.py new file mode 100644 index 0000000..b7b700c --- /dev/null +++ b/logger.py @@ -0,0 +1,18 @@ +#!/usr/bin/env python3 + +"""Module used for obtaining (pod, username, password) tuple. + +Used by me when I want to debug in public places and not want to show +my password. +""" + +import getpass + + +def getdata(): + """Asks for data. + """ + pod = input('Pod: ') + username = input('Username at \'{0}\': '.format(pod)) + password = getpass.getpass('Password for {0}@{1}: '.format(username, pod)) + return (pod, username, password)