1 Star 0 Fork 0

黄珍香 / cn-bloaty

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
regen-readme.py 698 Bytes
一键复制 编辑 原始数据 按行查看 历史
黄珍香 提交于 2022-01-11 18:52 . first commit
#!/usr/bin/env python
import subprocess
import os
import sys
basedir = os.path.dirname(sys.argv[0])
readme = os.path.join(basedir, "doc/using.md")
with open(readme) as f:
inp = f.read()
out = ""
it = iter(inp.splitlines(True))
for line in it:
out += line
if line.startswith("```cmdoutput"):
# Get command.
cmd = next(it)
assert cmd.startswith("$ "), cmd
real_cmd = cmd[2:].strip()
out += cmd
print("Running: " + real_cmd)
out += subprocess.check_output(real_cmd, shell=True)
# Skip pre-existing command output.
line = next(it)
while not line.startswith("```"):
line = next(it)
out += line
with open(readme, "w") as f:
f.write(out)
1
https://gitee.com/chouchouya/cn-bloaty.git
git@gitee.com:chouchouya/cn-bloaty.git
chouchouya
cn-bloaty
cn-bloaty
master

搜索帮助