1 Star 0 Fork 0

bluesubmarine/mastering-stm32

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
chmove.py 1.11 KB
一键复制 编辑 原始数据 按行查看 历史
#!/usr/bin/python
#
# This tool is used to "rename" chapter examples.
#
import sys, os
DRYRUN = 0
start = 17
end = 21
print "Retrieving projects list...."
projectDirs = [d for d in os.listdir(os.getcwd()) if d.startswith("nucleo-")]
for i in reversed(range(start, end+1)):
srcCH = "ch%d" % i
dstCH = "ch%d" % (i + 1)
srcCHdes = "Chapter %d" % i
dstCHdes = "Chapter %d" % (i + 1)
print "Moving %s to %s" % (srcCH, dstCH)
for projectDir in projectDirs:
cproject = open(os.path.join(os.getcwd(), projectDir, ".cproject"), "r+")
cprojectData = cproject.read()
cprojectData = cprojectData.replace(srcCH, dstCH)
cprojectData = cprojectData.replace(srcCH.upper(), dstCH.upper())
cprojectData = cprojectData.replace(srcCHdes, dstCHdes)
cproject.seek(0)
print "Changing projects: ", cproject.name
if not DRYRUN:
cproject.write(cprojectData)
cproject.close()
try:
print "Renaming directory: ", os.path.join(os.getcwd(), projectDir, "src", srcCH)
if not DRYRUN:
os.rename(os.path.join(os.getcwd(), projectDir, "src", srcCH), os.path.join(os.getcwd(), projectDir, "src", dstCH))
except OSError:
pass
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C
1
https://gitee.com/lukeson/mastering-stm32.git
[email protected]:lukeson/mastering-stm32.git
lukeson
mastering-stm32
mastering-stm32
master

搜索帮助