Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from jinja2 import Template
- js_template="""
- function drawChart137() {
- var columns = {{columns}};
- var title = "{{title}}";
- return [title, columns];
- }
- """
- template=Template(js_template)
- js_script=template.render(title=title, columns = columns)
- from py_mini_racer import py_mini_racer
- ctx = py_mini_racer.MiniRacer()
- ctx.eval(js_script)
- title, columns = ctx.call("drawChart137")
- def build_dict(script_list):
- wait_times = dict()
- ctx = py_mini_racer.MiniRacer()
- for script in script_list:
- #title and columns are in JavaScript format
- title, columns = extract_dates(script.text)
- print(title)
- js_template="""
- function drawChart137() {
- var columns = {{columns}};
- var title = "{{title}}";
- return [title, columns];
- }
- """
- template=Template(js_template)
- #generate JavaScript dynamically and execute it
- js_script=template.render(title=title, columns = columns)
- ctx.eval(js_script)
- #title and columns are Python objects
- title, columns = ctx.call("drawChart137")
- #build up wait times dictionary for each ride
- wait_times[title] = columns
- return wait_times
- wait_times_by_ride = build_dict(all_rides)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement