1 Star 0 Fork 0

小胖/gradio

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
render_readme.py 984 Bytes
一键复制 编辑 原始数据 按行查看 历史
Ali Abid 提交于 2021-02-26 10:51 . updated readme
import re
import os
from string import Template
with open("readme_template.md") as readme_file:
readme = readme_file.read()
codes = re.findall(r'\$code_([^\s]*)', readme)
demos = re.findall(r'\$demo_([^\s]*)', readme)
template_dict = {}
for code_src in codes:
with open(os.path.join("demo", code_src + ".py")) as code_file:
python_code = code_file.read()
python_code = python_code.replace('if __name__ == "__main__":\n iface.launch()', "iface.launch()")
if python_code.startswith("# Demo"):
python_code = "\n".join(python_code.split("\n")[2:])
template_dict["code_" + code_src] = "```python\n" + python_code + "\n```"
for demo_src in demos:
template_dict["demo_" + demo_src] = "![" + demo_src + " interface](demo/screenshots/" + demo_src + "/1.gif)"
readme_template = Template(readme)
output_readme = readme_template.substitute(template_dict)
with open("README.md", "w") as readme_md:
readme_md.write(output_readme)
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/phillip_huang/gradio.git
[email protected]:phillip_huang/gradio.git
phillip_huang
gradio
gradio
master

搜索帮助