def antFileAction(path, key, action, value = "1"): antFile = path + s_antPath fp = open(antFile, "r") str = fp.read() fp.close() #查找的位置 findKeyIndex = str.find(key) #没有找到,直接退出 if findKeyIndex == -1: print antFile,"Not Found",key return index = len(key) #取到开始的字符 lastText = str[0 : findKeyIndex + index] #取到之后的字符 nextText = str[findKeyIndex + index: ] #查找下一个回车 nexiIndex = nextText.find("\n") #分割下个字符串 if -1 == nexiIndex: nexiIndex = len(nextText) #剩下的就是version findValue = nextText[0 : nexiIndex] if action == s_getAction: return findValue elif action == s_wirteAction: valueNextText = nextText[nexiIndex: ] text = lastText + "=" + value + valueNextText FileUtils.writeFile(antFile , text)
def antFileAction(path, key, action, value="1"): antFile = path + s_antPath fp = open(antFile, "r") str = fp.read() fp.close() #查找的位置 findKeyIndex = str.find(key) #没有找到,直接退出 if findKeyIndex == -1: print antFile, "Not Found", key return index = len(key) #取到开始的字符 lastText = str[0:findKeyIndex + index] #取到之后的字符 nextText = str[findKeyIndex + index:] #查找下一个回车 nexiIndex = nextText.find("\n") #分割下个字符串 if -1 == nexiIndex: nexiIndex = len(nextText) #剩下的就是version findValue = nextText[0:nexiIndex] if action == s_getAction: return findValue elif action == s_wirteAction: valueNextText = nextText[nexiIndex:] text = lastText + "=" + value + valueNextText FileUtils.writeFile(antFile, text)
def check_folder_for_orm(repo_root, dir, outFile): for root, dirs, files in os.walk(os.path.join(repo_root, dir)): files = [f for f in files if not f[0] == '.'] dirs[:] = [d for d in dirs if not d[0] == '.'] for file in files: result = check_file_for_orm(os.path.join(root, file)) if (result != "NoORM"): FileUtils.writeFile(outFile, dir + "," + result) return FileUtils.writeFile(outFile, dir + "," + "NoORM")