Пример #1
0
def linux_readme(data):
    master_tmpl = template('linux_readme_master.tmpl')
    row_tmpl = template('linux_driver_row.tmpl', True)
    link_tmpl = template('markdown_link.tmpl', True)
    md_true = template('markdown_true.tmpl', True).substitute()
    md_false = template('markdown_false.tmpl', True).substitute()
    drivers = sorted(data['drivers'], key=linux_driver_key)

    def row_gen():
        for drv in drivers:
            driver_url = drv.get('driver_url')
            if driver_url:
                driver_link = link_tmpl.substitute(text="Driver link",
                                                   url=driver_url)
            else:
                driver_link = ''
            nvenc_patch = md_true if drv['nvenc_patch'] else md_false
            nvfbc_patch = md_true if drv['nvfbc_patch'] else md_false
            yield row_tmpl.substitute(version=drv['version'],
                                      nvenc_patch=nvenc_patch,
                                      nvfbc_patch=nvfbc_patch,
                                      driver_link=driver_link)

    version_list = "\n".join(row_gen())
    latest_version = drivers[-1]['version']
    example_driver = find_driver(drivers, linux_driver_key(data['example']),
                                 linux_driver_key)
    example_driver_url = example_driver['driver_url']
    return master_tmpl.substitute(
        version_list=version_list,
        latest_version=latest_version,
        example_driver_url=example_driver_url,
        example_driver_version=example_driver['version'],
        example_driver_file=os.path.basename(example_driver_url))
Пример #2
0
def validate_unique(drivers, new_driver, kf):
    if find_driver(drivers, kf(new_driver), kf) is not None:
        raise Exception("Duplicate driver!")