Skip to content

Commit e636d2f

Browse files
committed
have something functional now. item fetching is wrapped
0 parents  commit e636d2f

13 files changed

+72
-0
lines changed

MANIFEST.in

Whitespace-only changes.

README

Whitespace-only changes.

pyzootool/__init__.py

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
## Globals
2+
ROOT_URL = "http://zootool.com"

pyzootool/__init__.pyc

201 Bytes
Binary file not shown.

pyzootool/auth.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
class ZooAuth():
3+
pass

pyzootool/auth.pyc

368 Bytes
Binary file not shown.

pyzootool/controller.py

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"""
2+
Central point for pyzootool's control
3+
"""
4+
import httplib2
5+
from pyzootool import auth, items, users
6+
7+
class ZooControl():
8+
9+
def __init__(self, apikey, username=None, password=None):
10+
self.apikey = apikey
11+
self.http = httplib2.Http()
12+
if username and password:
13+
## TODO: Implement this
14+
self.auth = auth.ZooAuth(self.api_key, username, password)
15+
self.item = items.ZooItem(self.apikey, self.http)
16+
#self.user = users.ZooUser(self.apikey, self.http)

pyzootool/controller.pyc

990 Bytes
Binary file not shown.

pyzootool/items.py

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import json
2+
import urllib
3+
4+
from pyzootool import ROOT_URL
5+
6+
class ZooResult():
7+
8+
def __init__(self, json_data):
9+
self.parse_results(json_data)
10+
11+
def parse_results(self, json_data):
12+
print json_data
13+
self.uid = json_data['uid']
14+
self.title = json_data['title']
15+
self.url = json_data['url']
16+
self.type = json_data['type']
17+
self.views = json_data['views']
18+
self.likes = json_data['likes']
19+
self.permalink = json_data['permalink']
20+
self.tinyurl = json_data['tinyurl']
21+
self.thumbnail = json_data['thumbnail']
22+
23+
class ZooItem():
24+
25+
def __init__(self, apikey, http):
26+
self.apikey = apikey
27+
self.http = http
28+
29+
30+
def get_item(self, item_id):
31+
values = {'uid': item_id, 'apikey': self.apikey}
32+
url = "%s/api/items/info/?%s" % (
33+
ROOT_URL, urllib.urlencode(values)
34+
)
35+
resp, content = self.http.request(url)
36+
json_data = json.loads(content)
37+
result = ZooResult(item)
38+
return zoo_results
39+
40+
def get_popular(self, pop_type):
41+
values = {'type': pop_type, 'apikey': self.apikey }
42+
url = "%s/api/items/popular/?%s" % (
43+
ROOT_URL, urllib.urlencode(values)
44+
)
45+
resp, content = self.http.request(url)
46+
json_data = json.loads(content)
47+
zoo_results = []
48+
for item in json_data:
49+
result = ZooResult(item)
50+
zoo_results.append(result)
51+
return zoo_results

pyzootool/items.pyc

2.52 KB
Binary file not shown.

pyzootool/users.py

Whitespace-only changes.

pyzootool/users.pyc

156 Bytes
Binary file not shown.

setup.py

Whitespace-only changes.

0 commit comments

Comments
 (0)