Skip to content

Commit

Permalink
Broke into 2 files
Browse files Browse the repository at this point in the history
  • Loading branch information
johnfn committed Apr 16, 2011
1 parent 036d84c commit 3ca029c
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 49 deletions.
Empty file added __init__.py
Empty file.
22 changes: 2 additions & 20 deletions broadband_api.py
Original file line number Original file line Diff line number Diff line change
@@ -1,25 +1,7 @@
import urllib from generic_api import *
import json

# Inheritable class to perform requests to generic APIs.
class BaseAPIRequest:
def __init__(self, url):
self.url = url

#Inherit this method to describe how to format URLs.
def format_url(self):
pass

# Requests the API and returns the JSON object.
def request(self, **args):
self.format_url(**args)
object = json.loads("".join([l for l in urllib.urlopen(self.url)]))
return object





# Simple Python wrapper around the Broadband API provided by the FCC. # Simple Python wrapper around the Broadband API provided by the FCC.

class BroadbandApi(BaseAPIRequest): class BroadbandApi(BaseAPIRequest):
def __init__(self): def __init__(self):
BaseAPIRequest.__init__(self, "http://data.fcc.gov/api/speedtest/find?latitude=%s&longitude=%s&format=json") BaseAPIRequest.__init__(self, "http://data.fcc.gov/api/speedtest/find?latitude=%s&longitude=%s&format=json")
Expand Down
29 changes: 0 additions & 29 deletions fcc_api.py

This file was deleted.

17 changes: 17 additions & 0 deletions generic_api.py
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,17 @@
import urllib
import json

# Inheritable class to perform requests to generic APIs.
class BaseAPIRequest:
def __init__(self, url):
self.url = url

#Inherit this method to describe how to format URLs.
def format_url(self):
pass

# Requests the API and returns the JSON object.
def request(self, **args):
self.format_url(**args)
object = json.loads("".join([l for l in urllib.urlopen(self.url)]))
return object
Binary file added generic_api.pyc
Binary file not shown.

0 comments on commit 3ca029c

Please sign in to comment.