Commits

Jordan Orelli  committed f0792dc

wrote sample templates

  • Participants
  • Parent commits dc6c1ed

Comments (0)

Files changed (13)

File foursquare/__init__.py

Empty file removed.

File foursquare/__init__.pyc

Binary file removed.

File foursquare/api.py

-import urllib
-import urllib2
-import json
-
-class FoursquareCall(object):
-    pass
-
-class Foursquare(object):
-    """
-    A minimalist Foursquare API v2 class.
-
-    The Foursquare v2 is structured by resources and aspects, and optional params:
-    http://api.foursquare.com/v2/RESOURCE/RESOURCE_ID/ASPECT?key1=val1&...
-        e.g. http://api.foursquare.com/v2/users/12345
-        e.g. http://api.foursquare.com/v2/users/12345/checkins?limit=10
-    See http://developer.foursquare.com for details.
-
-    Data is available by accessing class members; the data is returned as
-    normal Python data objects (lists and dictionaries).
-
-    For example:
-    fsq = Foursquare(auth) or Foursquare()
-    fsq.users(id=12345)  # /users/12345
-    fsq.users.friends(id=12345, limit=10)  # /users/12345/friends?limit=10
-
-    The id parameter is the resource id; if blank, 'self' will be used.
-    """
-    API_BASE_URI = 'http://api.foursquare.com/v2'
-
-    def __init__(self, auth=None, resource=None, aspect=None):
-        """
-        A new Foursquare API instance.
-        TODO: describe params
-        """
-        self.auth = auth
-        self.resource = resource
-        self.aspect = aspect
-
-    def __getattr__(self, m):
-        try:
-            return object.__getattr__(self, m)
-        except AttributeError:
-            if not self.resource:
-                return Foursquare(auth=self.auth, resource=m)
-            else:
-                return Foursquare(auth=self.auth, resource=self.resource,
-                                  aspect=m)
-
-    def __call__(self, **kwargs):
-        resource_id = str(kwargs.pop('id', 'self'))
-        if self.auth.token:
-            kwargs['oauth_token'] = self.auth.token
-
-        # build the url
-        if self.aspect:
-            uri = '%s/%s/%s/%s?%s' % (Foursquare.API_BASE_URI, self.resource,
-                                      resource_id, self.aspect,
-                                      urllib.urlencode(kwargs))
-        else:
-            uri = '%s/%s/%s?%s' % (Foursquare.API_BASE_URI, self.resource,
-                                   resource_id, urllib.urlencode(kwargs))
-
-        # request the data from foursquare
-        # TODO: handle various exceptions here...
-        request = urllib2.Request(uri)
-        response = urllib2.urlopen(request)
-
-        # parse response json and return
-        return json.loads(response.read())

File foursquare/api.pyc

Binary file removed.

File foursquare/example.py

-import os
-from pprint import pprint
-
-from api import Foursquare
-from oauth import OAuth
-
-if __name__ == '__main__':
-
-    # say hello and ask for foursquare email/phone
-    print('Foursquare API')
-    print('--------------\n')
-    username = raw_input('Email associated with your Foursquare account: ').strip()
-
-    # build oauth obj, do oauth_dance if oath_token not available
-    oauth_fname = '%s.token' % username
-    if not os.path.exists(oauth_fname):
-        raise Exception('need to do OAuth token getting blaaaah...')
-    else:
-        oauth_token = open(oauth_fname, 'r').readlines()[0]
-        oauth_token = oauth_token.strip()
-    auth = OAuth(oauth_token)
-
-    # make our foursquare object
-    fsq = Foursquare(auth=auth)
-
-    # foursquare api requests
-    phil_id = 5804431
-    me = fsq.users()
-    my_friends = fsq.users.friends(id=phil_id)
-    pprint(me)

File foursquare/oauth.py

-# TODO: noauth object
-
-class OAuth(object):
-
-    def __init__(self, token):
-        self.token = token

File lib/foursquare/__init__.py

Empty file added.

File lib/foursquare/__init__.pyc

Binary file added.

File lib/foursquare/api.py

+import urllib
+import urllib2
+import json
+
+class FoursquareCall(object):
+    pass
+
+class Foursquare(object):
+    """
+    A minimalist Foursquare API v2 class.
+
+    The Foursquare v2 is structured by resources and aspects, and optional params:
+    http://api.foursquare.com/v2/RESOURCE/RESOURCE_ID/ASPECT?key1=val1&...
+        e.g. http://api.foursquare.com/v2/users/12345
+        e.g. http://api.foursquare.com/v2/users/12345/checkins?limit=10
+    See http://developer.foursquare.com for details.
+
+    Data is available by accessing class members; the data is returned as
+    normal Python data objects (lists and dictionaries).
+
+    For example:
+    fsq = Foursquare(auth) or Foursquare()
+    fsq.users(id=12345)  # /users/12345
+    fsq.users.friends(id=12345, limit=10)  # /users/12345/friends?limit=10
+
+    The id parameter is the resource id; if blank, 'self' will be used.
+    """
+    API_BASE_URI = 'http://api.foursquare.com/v2'
+
+    def __init__(self, auth=None, resource=None, aspect=None):
+        """
+        A new Foursquare API instance.
+        TODO: describe params
+        """
+        self.auth = auth
+        self.resource = resource
+        self.aspect = aspect
+
+    def __getattr__(self, m):
+        try:
+            return object.__getattr__(self, m)
+        except AttributeError:
+            if not self.resource:
+                return Foursquare(auth=self.auth, resource=m)
+            else:
+                return Foursquare(auth=self.auth, resource=self.resource,
+                                  aspect=m)
+
+    def __call__(self, **kwargs):
+        resource_id = str(kwargs.pop('id', 'self'))
+        if self.auth.token:
+            kwargs['oauth_token'] = self.auth.token
+
+        # build the url
+        if self.aspect:
+            uri = '%s/%s/%s/%s?%s' % (Foursquare.API_BASE_URI, self.resource,
+                                      resource_id, self.aspect,
+                                      urllib.urlencode(kwargs))
+        else:
+            uri = '%s/%s/%s?%s' % (Foursquare.API_BASE_URI, self.resource,
+                                   resource_id, urllib.urlencode(kwargs))
+
+        # request the data from foursquare
+        # TODO: handle various exceptions here...
+        request = urllib2.Request(uri)
+        response = urllib2.urlopen(request)
+
+        # parse response json and return
+        return json.loads(response.read())

File lib/foursquare/api.pyc

Binary file added.

File lib/foursquare/example.py

+import os
+from pprint import pprint
+
+from api import Foursquare
+from oauth import OAuth
+
+if __name__ == '__main__':
+
+    # say hello and ask for foursquare email/phone
+    print('Foursquare API')
+    print('--------------\n')
+    username = raw_input('Email associated with your Foursquare account: ').strip()
+
+    # build oauth obj, do oauth_dance if oath_token not available
+    oauth_fname = '%s.token' % username
+    if not os.path.exists(oauth_fname):
+        raise Exception('need to do OAuth token getting blaaaah...')
+    else:
+        oauth_token = open(oauth_fname, 'r').readlines()[0]
+        oauth_token = oauth_token.strip()
+    auth = OAuth(oauth_token)
+
+    # make our foursquare object
+    fsq = Foursquare(auth=auth)
+
+    # foursquare api requests
+    phil_id = 5804431
+    me = fsq.users()
+    my_friends = fsq.users.friends(id=phil_id)
+    pprint(me)

File lib/foursquare/oauth.py

+# TODO: noauth object
+
+class OAuth(object):
+
+    def __init__(self, token):
+        self.token = token

File team/views.pyc

Binary file modified.