1 Star 0 Fork 0

toliong/myscript

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
filter_keywords.py 679 Bytes
一键复制 编辑 原始数据 按行查看 历史
toliong 提交于 2017-02-14 14:15 . Add filter_keywords.py
#!/usr/bin/env python
#
#--*-- encoding:UTF-8 --*--
#
import os
import re
AllVersion = ['alpha','beta','staging','gamma','delta']
ConfigFilePath = '/opt/nginx/conf/vhosts'
def PatternExists(filename,pattern):
"if pattern can be founded in filename, print that line."
with open(filename) as openfile:
content = openfile.readlines()
for each_line in content:
if re.findall(pattern, each_line):
print filename +" ## "+ each_line
#PatternExists('/etc/passwd','root')
os.chdir(ConfigFilePath)
for each_file in os.listdir(ConfigFilePath):
for each_item in AllVersion:
if re.findall(each_item,each_file):
continue
else:
PatternExists(each_file,each_item)
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Shell
1
https://gitee.com/toliong/myscript.git
git@gitee.com:toliong/myscript.git
toliong
myscript
myscript
master

搜索帮助