Phuket2
Oct 14, 2017 - 14:57
Guys I come across this project today via another forum. Very interesting. @ccc I think you would like this one if you dont all ready know about it. I was able to install the jsoncut package with StaSh(I have only tried that one). I am struggling a little because of my experience, but it looks great. Below is just me starting out trying to understand what it can do. But looks exciting to me, just thought I would share.
import ui
import jsoncut
import requests
import json
import os
_url = "http://ergast.com/api/f1/drivers.json"
_filename = 'f1driver_info.json'
def get_drivers_details():
if os.path.exists(_filename):
with open(_filename) as infile:
print("data from file")
return json.load(infile)
else:
response = requests.get(_url)
with open(_filename, 'w') as outfile:
json.dump(response.json(), outfile)
print("data from web")
return response.json()
class MyClass(ui.View):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.make_view()
def make_view(self):
pass
if __name__ == '__main__':
j_drivers = get_drivers_details()
#print(j_drivers)
#print(dir(jsoncut.inspector))
print('-------Inspect-------')
x = jsoncut.inspector.inspect_json(j_drivers)
for elm in x:
print(elm)
#print(help(jsoncut.inspector.get_children))
print('-------Children-------')
x = jsoncut.inspector.key_crawler(j_drivers)
for elm in x:
print(elm)
print('-------TreeWalker-------')
x = jsoncut.inspector.tree_walker(j_drivers)
for elm in x:
print(elm)
f = (0, 0, 300, 400)
v = MyClass(frame=f)
v.present(style='sheet', animated=False)