def stripAxisCode(fileName):
"""copy lines from in file to out file up to first occurance
of the string 'org.apache.axis', then just write closing brace.
hasAxisCode detects of the file was already processed such that
this is an idempotent operation.
"""
hasAxisCode = False
fin = open(fileName, 'r')
outName = ''.join([fileName, '.tmp'])
fout = open(outName, 'wr')
for line in fin:
if (string.find(line, 'org.apache.axis') != -1 and
string.find(line, 'extends') == -1 and
string.find(line, 'implements') == -1):
hasAxisCode = True
break
else:
fout.write(line)
fin.close()
if hasAxisCode:
fout.write("}\n")
fout.close
shutil.move(outName, fileName)
评论列表
文章目录