import os
import re
#all file in the directory
filelist = []
#function to traverse the directory
def recurseDir(path):
for i in os.listdir(path):
if os.path.isdir(path + '\' + i):
recurseDir(path + '\' + i)
else:
p = path + '\' + i
print p
filelist.append(p)
#replace the file content
def replace(strFind, strReplace, lines, fileIO):
for s in lines:
if s.find(strFind) != -1:
foutput.write(s)
fileIO.write(s.replace(strFind, strReplace))
rootpath = os.path.abspath('.')
recurseDir(rootpath)
pattern1 = re.compile(r'.+html')
pattern2 = re.compile(r'.+js')
for fileName in filelist:
match1 = pattern1.match(fileName)
match2 = pattern2.match(fileName)
if match1 or match2:
lines = open(fileName).readlines()
fp = open(fileName + '.temp','w')
foutput = open("result.txt", 'w')
foutput.write(fileName)
if match1:
replace('<include file="./Tpl/', '<include file="./App/Tpl/', lines, fp)
if match2:
replace('xxx/index.php', 'index.php', lines, fp)
fp.close()
#delete original file
if os.path.exists(fileName):
os.remove(fileName);
#rename the temp file
os.rename(fileName + '.temp', fileName)
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有