Rui Vieira avatar Rui Vieira committed a0b2507

Somewhat saner method and variable names

Comments (0)

Files changed (1)

 
     def fetch(self):
         if self.id != "":
-            data = fetchGSON(_getProfileURL(self.id))
-            self._fetchGSON(data)
+            json = fetchJSON(_getProfileURL(self.id))
+            self._populate(json)
 
-    def _fetchGSON(self, data):
-        self.avatar = "https:" + data[1][2][3]
-        self.firstName = data[1][2][4][1]
-        self.surname = data[1][2][4][2]
-        self.biopic = data[1][2][14][1]
-        self.blurb = data[1][2][33][1]
+    def _populate(self, json):
+        self.avatar = "https:" + json[1][2][3]
+        self.firstName = json[1][2][4][1]
+        self.surname = json[1][2][4][2]
+        self.biopic = json[1][2][14][1]
+        self.blurb = json[1][2][33][1]
 
 
 class Post:
         self.data = ""
         self.sharedId = ""
 
-    def _getGSON(self, data ):
-        self.postId = data[21]
-        self.authorId = data[16]
-        self.shared = data[47]
-        self.data = data[4]
-        self.sharedId = data[77]
+    def _populate(self, json ):
+        self.postId = json[21]
+        self.authorId = json[16]
+        self.shared = json[47]
+        self.data = json[4]
+        self.sharedId = json[77]
 
     def getUpdateID(self):
         updateId = ""
     # this updates a single post
     def _fetch(self):
         if self.postId != "":
-            jsondata = fetchGSON(_getPostURL(self.getAuthorIDFromPostID(), self.getUpdateID()))
-            self._getGSON(jsondata[1])
+            jsondata = fetchJSON(_getPostURL(self.getAuthorIDFromPostID(), self.getUpdateID()))
+            self._populate(jsondata[1])
 
 
 def fetchPosts(id):
-    data = fetchGSON(_getPostsURL(id))
+    data = fetchJSON(_getPostsURL(id))
     activities = data[1][0]
 
     posts = []
     for postdata in activities:
         post = Post()
-        post._getGSON(postdata)
+        post._populate(postdata)
         posts.append(post)
     return posts
 
 
-def fetchGSON(url):
+def fetchJSON(url):
     response = urllib.urlopen(url).read()
-    response = parseGSON(response)
+    response = _parseGSON(response)
     return json.loads(response)
 
 
 def fetchVisiblePeople(id):
     people = []
     if id != "":
-        data = fetchGSON(_getVisibleURL(id))
+        data = fetchJSON(_getVisibleURL(id))
         visible = data[2]
         regexp = re.compile('/^([\w\.\s]+) (\w+)$/')
         for response in visible:
 def fetchIncomingPeople(id):
     people = []
     if id != "":
-        data = fetchGSON(_getVisibleURL(id))
+        data = fetchJSON(_getVisibleURL(id))
         incoming = data[2]
 
         regexp = re.compile('/^([\w\.\s]+) (\w+)$/')
 #
 # Parse Google+ pseudo-JSON format into JSON
 #
-def parseGSON(gson):
+def _parseGSON(gson):
     gson = gson[5:]
     result = ''
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.