Improvements to the documentation and style fixes
authorMoritz Kiefer <moritz.kiefer@gmail.com>
Fri, 18 Jan 2013 11:53:57 +0000 (12:53 +0100)
committerMoritz Kiefer <moritz.kiefer@gmail.com>
Fri, 18 Jan 2013 11:53:57 +0000 (12:53 +0100)
.gitignore
diaspy/client.py
diaspy/models.py
docs/source/conf.py
docs/source/index.rst

index c5edd0715e067b5b198f583fb1930014c08f1d2a..269358f337ca594544890ba98678535e4c6145c3 100644 (file)
@@ -1,6 +1,7 @@
 *~
 *.swp
 docs/build/*
-*__pycache__/*
+*/__pycache__/*
+__pycache__/*
 .env
 
index c21a6b4347460fa4333badde2ef02f3677bba938..b1ad81f0a43f2ae27cf6d70df18b4a6e10cfdc6e 100644 (file)
@@ -19,11 +19,16 @@ class Client:
         self.session = requests.Session()
 
     def get_token(self):
+        """This function gets a token needed for authentication in most cases
+
+        :returns: string -- token used to authenticate
+
+        """
+
         r = self.session.get(self.pod + "/stream")
         token = self._token_regex.search(r.text).group(1)
         return token
 
-
     def login(self, username, password):
         """This function is used to connect to the pod and log in.
 
index ea22b45d3d6a76a212d0362584d86860d9ae5f14..8da32a6beea6b0ab39e44e1aa1bf913abe30267c 100644 (file)
@@ -1,9 +1,30 @@
 import requests
+
+
 class Post:
+    """This class represents a post.
+
+    .. note::
+        Remember that you need to have access to the post.
+
+    :params post_id: id or guid of the post
+    :type post_id: str
+    :params client: client object used to authenticate
+    :type client: Client
+
+    .. note::
+        The login function of the client should be called,
+        before calling any of the post functions.
+
+    """
 
     def __init__(self, post_id, client):
+
         self._client = client
-        r = self._client.session.get(self._client.pod + '/posts/' + post_id + '.json')
+        r = self._client.session.get(self._client.pod +
+                                     '/posts/' +
+                                     post_id +
+                                     '.json')
         if r.status_code == 200:
             self.data = r.json()
         else:
@@ -33,10 +54,11 @@ class Post:
 
         data = {'authenticity_token': self._client.get_token()}
 
-        r = self._client.session.delete(self._client.pod + '/posts/' + 
+        r = self._client.session.delete(self._client.pod + '/posts/' +
                                         str(self.data['id']) +
                                         '/likes/' +
-                                        str(self.data['interactions']['likes'][0]['id']),
+                                        str(self.data['interactions']
+                                            ['likes'][0]['id']),
                                         data=data)
 
     def reshare(self):
@@ -66,10 +88,14 @@ class Post:
         data = {'text': text,
                 'authenticity_token': self._client.get_token()}
 
-        r = self._client.session.post(self._client.pod + '/posts/' + str(self.data['id']) + '/comments', data=data)
+        r = self._client.session.post(self._client.pod +
+                                      '/posts/' +
+                                      str(self.data['id']) +
+                                      '/comments',
+                                      data=data)
 
         return r.json()
-    
+
     def rmcomment(self, comment_id):
         """This function removes a comment from a post
 
@@ -82,8 +108,8 @@ class Post:
 
         data = {'authenticity_token': self._client.get_token()}
 
-        r = self._client.session.delete(self._client.pod + '/posts/' + 
-                                str(self.data['id']) +
-                                '/comments/' +
-                                comment_id,
-                                data=data)
+        r = self._client.session.delete(self._client.pod + '/posts/' +
+                                        str(self.data['id']) +
+                                        '/comments/' +
+                                        comment_id,
+                                        data=data)
index 7f47030e4dbb9f28a8ba5f8f6ece4da191cf9872..a523cd2e482e421756cb48b2e7d091aa674037b7 100644 (file)
@@ -18,7 +18,7 @@ import sys, os
 # add these directories to sys.path here. If the directory is relative to the
 # documentation root, use os.path.abspath to make it absolute, like shown here.
 #sys.path.insert(0, os.path.abspath('.'))
-sys.path.insert(0, os.path.abspath(os.path.join(os.pardir, os.pardir)))
+sys.path.insert(0, os.path.abspath(os.path.join(os.pardir, os.pardir, 'diaspy')))
 
 # -- General configuration -----------------------------------------------------
 
index 81902f30e871e37918d32c4fc58100c0e6da4a51..3cc90e683167380482e57963db96f26058ba503c 100644 (file)
@@ -11,9 +11,7 @@ Contents:
 .. toctree::
    :maxdepth: 2
 
-.. automodule:: diaspy
-    :members:
-
+   modules
 
 Indices and tables
 ==================