#!/usr/bin/env python
# -*- coding: UTF-8 -*-
'''
Created on Mar 5, 2015
@author: lqp
'''
import os
import re
import os.path as pathUtil
bbLogRegPattern = re.compile(r'(^\s*)(BBLog\.[^;]+;)', re.DOTALL | re.MULTILINE);
normalLogRegPattern = re.compile(r'(^\s*)(Log\.[^;]+;)', re.DOTALL | re.MULTILINE);
workDir = '..';
srcFolder = ['app/src/main/java',
'bbcomm/src/main/java',
'comm/src/main/java'
];
processCount = 0
def listFiles(path, outList):
files = os.listdir(path);
for item in files:
item = path + pathUtil.sep + item;
if pathUtil.isdir(item):
listFiles(item, outList);
else:
if pathUtil.splitext(item)[1] == '.java':
outList.append(item)
return
def processFile(fileName):
srcFile = open(fileName, "r");
content = srcFile.read()
srcFile.close()
global workDir
needWrite = 0
#replace BBlog
groups = bbLogRegPattern.findall(content);
if len(groups) > 0:
global processCount
print 'purge BBLog in: ' + pathUtil.relpath(fileName, workDir);
content = re.sub(bbLogRegPattern, r'\1//BBLog call replaced', content);
needWrite = 1
##replace Log.x()
groups = normalLogRegPattern.findall(content);
if len(groups) > 0:
global processCount
print 'purge Log.x in: ' + pathUtil.relpath(fileName, workDir);
content = re.sub(normalLogRegPattern, r'\1//Log.x call replaced', content);
needWrite = 1
if needWrite:
srcFile = open(fileName, "w");
srcFile.write(content)
srcFile.close()
processCount = processCount + 1
return
if __name__ == '__main__':
holderList = []
workDir = pathUtil.abspath(workDir)
print 'start work at dir: ' + workDir
for folder in srcFolder:
listFiles(workDir + os.path.sep + folder, holderList);
for item in holderList:
processFile(item)
print 'process complete: ' + str(processCount) + ' files changed'
pass
去掉AS工程中的log
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
推荐阅读更多精彩内容
- 小学语文修改病句的方法 修改病句是小学语文考试中常见的题型,在修改病句之前,我们应该清晰的了解有哪些病句现象,下面...
- 解决方法:Xcode8里边 Edit Scheme... -> Run -> Arguments,(快捷键:shi...