From ce8964ff7661ea3b11c69fb1c38674c2c4a0af97 Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Sun, 16 May 2010 14:20:52 -0400 Subject: [PATCH] general cleanup --- gist/gist.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/gist/gist.py b/gist/gist.py index 8be48ee..2ce8184 100644 --- a/gist/gist.py +++ b/gist/gist.py @@ -69,17 +69,17 @@ class Gist(object): _meta = self._json setattr(self, 'id', _meta['repo']) else: + # Fetch Gist metadata _meta_url = 'http://gist.github.com/api/v1/json/{0}'.format(self.id) _meta = json.load(urllib.urlopen(_meta_url))['gists'][0] - # Get all response properties for key, value in _meta.iteritems(): if key == 'files': # Remap file key from API setattr(self, 'filenames', value) else: - # Attach given to oject + # Attach properties to object setattr(self, key, value) return _meta @@ -90,6 +90,7 @@ class Gist(object): files = {} for fn in self.filenames: + # Grab file contents file_url = 'http://gist.github.com/raw/{0}/{1}'.format(self.id, fn) files[fn] = (urllib.urlopen(file_url).read()) @@ -107,7 +108,7 @@ class Gists(object): """Returns a set of public Gist objects owned by the given GitHub username""" _url = 'http://gist.github.com/api/v1/json/gists/{0}'.format(name) - + # Return a list of Gist objects return [Gist(json=g) for g in json.load(urllib.urlopen(_url))['gists']]