import json/simplejson in one place and use that
This commit is contained in:
parent
8569759865
commit
eae4803cd3
6 changed files with 19 additions and 18 deletions
|
|
@ -2,7 +2,8 @@
|
|||
# vi:si:et:sw=4:sts=4:ts=4
|
||||
# GPL 2009
|
||||
import os
|
||||
import simplejson
|
||||
|
||||
from ox.utils import json
|
||||
|
||||
|
||||
def get(key):
|
||||
|
|
@ -12,7 +13,7 @@ def get(key):
|
|||
f = open(user_auth, "r")
|
||||
data = f.read()
|
||||
f.close()
|
||||
auth = simplejson.loads(data)
|
||||
auth = json.loads(data)
|
||||
if key in auth:
|
||||
return auth[key]
|
||||
print "please add key %s to json file '%s'" % (key, user_auth)
|
||||
|
|
|
|||
|
|
@ -174,14 +174,14 @@ class ItunesMovie:
|
|||
return data
|
||||
|
||||
if __name__ == '__main__':
|
||||
import simplejson
|
||||
from ox.utils import json
|
||||
data = ItunesAlbum(title = 'So Red the Rose', artist = 'Arcadia').getData()
|
||||
print simplejson.dumps(data, sort_keys = True, indent = 4)
|
||||
print json.dumps(data, sort_keys = True, indent = 4)
|
||||
data = ItunesMovie(title = 'The Matrix', director = 'Wachowski').getData()
|
||||
print simplejson.dumps(data, sort_keys = True, indent = 4)
|
||||
print json.dumps(data, sort_keys = True, indent = 4)
|
||||
for v in data['relatedMovies']:
|
||||
data = ItunesMovie(id = v['id']).getData()
|
||||
print simplejson.dumps(data, sort_keys = True, indent = 4)
|
||||
print json.dumps(data, sort_keys = True, indent = 4)
|
||||
data = ItunesMovie(id='272960052').getData()
|
||||
print simplejson.dumps(data, sort_keys = True, indent = 4)
|
||||
print json.dumps(data, sort_keys = True, indent = 4)
|
||||
|
||||
|
|
|
|||
|
|
@ -128,7 +128,7 @@ def archiveIssues():
|
|||
'''
|
||||
p = {}
|
||||
import os
|
||||
import simplejson
|
||||
from ox.utils import json
|
||||
import time
|
||||
archivePath = '/Volumes/Rolux Home/Desktop/Data/spiegel.de/Der Spiegel'
|
||||
localtime = time.localtime()
|
||||
|
|
@ -148,7 +148,7 @@ def archiveIssues():
|
|||
os.makedirs(dirname)
|
||||
filename = '%s/Der Spiegel %d %02d.json' % (dirname, y, w)
|
||||
if not os.path.exists(filename):
|
||||
data = simplejson.dumps(issue, ensure_ascii = False)
|
||||
data = json.dumps(issue, ensure_ascii = False)
|
||||
f = open(filename, 'w')
|
||||
f.write(data)
|
||||
f.close()
|
||||
|
|
@ -193,7 +193,7 @@ def archiveNews():
|
|||
this is just an example of an archiving application
|
||||
'''
|
||||
import os
|
||||
import simplejson
|
||||
from ox.utils import json
|
||||
import time
|
||||
|
||||
count = {}
|
||||
|
|
@ -229,7 +229,7 @@ def archiveNews():
|
|||
else:
|
||||
filename = dirname + '/' + new['url'] + '.json'
|
||||
if not os.path.exists(filename) or True:
|
||||
data = simplejson.dumps(new, ensure_ascii = False)
|
||||
data = json.dumps(new, ensure_ascii = False)
|
||||
f = open(filename, 'w')
|
||||
f.write(data)
|
||||
f.close()
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
# vi:si:et:sw=4:sts=4:ts=4
|
||||
from urllib import urlencode
|
||||
|
||||
import simplejson
|
||||
from ox.utils import json
|
||||
from ox.cache import readUrl, readUrlUnicode
|
||||
from ox import findRe, decodeHtml
|
||||
|
||||
|
|
@ -109,7 +109,7 @@ def find(query, max_results=10):
|
|||
data = readUrl(url)
|
||||
if not data:
|
||||
data = readUrl(url, timeout=0)
|
||||
result = simplejson.loads(data)
|
||||
result = json.loads(data)
|
||||
results = []
|
||||
if result and 'query' in result:
|
||||
for r in result['query']['search']:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue