现在的位置: 首页 > 综合 > 正文

python 遍历修改工程下所有CVS/Root文件

2013年10月09日 ⁄ 综合 ⁄ 共 634字 ⁄ 字号 评论关闭

由于CVS修改,倒是现有工程无法提交已修改代码,而且也没有在Intell ida中找到修改全部CSV路径的方法,所以就写了个小脚本全给改了,哇嘎嘎~

#!/usr/bin/env python
#--*-- coding:utf-8 --*--

import os

list_path = r"F:\IntelliJIDEA_workspace\maven\sgh_findgame"

# os.walk(path),遍历path,返回一个对象,他的每个部分都是一个三元组,('目录x',[目录x下的目录list],目录x下面的文件
def walk_dir(dir,topdown=True):
    for root, dirs, files in os.walk(dir, topdown):
        for name in files:
            if name == "Root":
                file_full_path = os.path.join(root,name)
                with open(file_full_path, "w") as file :
                    file.writelines(":pserver:myName@cvsHost:/data/cvsroot") 

        for name in dirs: # 这个在该功能中没啥用
            if name == "Root":
                file_full_path = os.path.join(root,name)
                with open(file_full_path) as file :
                    print(file.readlines())

walk_dir(list_path)

抱歉!评论已关闭.