Example #1
0
def renderJSON(script_path, time_file_path):
    with copen(script_path, encoding='utf-8', errors='replace', newline='\r\n') as scriptf:
    # with open(script_path) as scriptf:
        with open(time_file_path) as timef:
            timing = getTiming(timef)
            ret = {}
            with closing(scriptf):
                scriptf.readline()  # ignore first header line from script file
                offset = 0
                for t in timing:
                    dt = scriptf.read(t[1])
                    offset += t[0]
                    ret[str(offset/float(1000))] = dt.decode('utf-8', 'replace')
    return dumps(ret)
Example #2
0
def renderJSON(script_path, time_file_path):
    with copen(script_path, encoding='utf-8', errors='replace', newline='\r\n') as scriptf:
        # with open(script_path) as scriptf:
        with open(time_file_path) as timef:
            timing = getTiming(timef)
            ret = {}
            with closing(scriptf):
                scriptf.readline()  # ignore first header line from script file
                offset = 0
                for t in timing:
                    dt = scriptf.read(t[1])
                    offset += t[0]
                    ret[str(offset/float(1000))] = dt.decode('utf-8', 'replace')
    return dumps(ret)
Example #3
0
def renderTemplate(script_path, time_file_path, dimensions=(24, 80), templatename=DEFAULT_TEMPLATE):
    with copen(script_path, encoding="utf-8", errors="replace", newline="\r\n") as scriptf:
        # with open(script_path) as scriptf:
        with open(time_file_path) as timef:
            timing = getTiming(timef)
            json = scriptToJSON(scriptf, timing)

    fsl = FileSystemLoader(dirname(templatename), "utf-8")
    e = Environment()
    e.loader = fsl

    templatename = basename(templatename)
    rendered = e.get_template(templatename).render(json=json, dimensions=dimensions)

    return rendered
Example #4
0
def renderTemplate(script_path, time_file_path, dimensions=(24, 80), templatename=DEFAULT_TEMPLATE):
    with copen(script_path, encoding='utf-8', errors='replace', newline='\r\n') as scriptf:
        # with open(script_path) as scriptf:
        with open(time_file_path) as timef:
            timing = getTiming(timef)
            json = scriptToJSON(scriptf, timing)

    fsl = FileSystemLoader(os.path.dirname(templatename), 'utf-8')
    e = Environment()
    e.loader = fsl

    templatename = os.path.basename(templatename)
    rendered = e.get_template(templatename).render(json=json,
                                                   dimensions=dimensions)

    return rendered