python 小脚本

#!/usr/bin/env python
import os

dirpath="/data"
ext=".php"
key="system"
x=[]
y=[]
z=[]
def _isdir(path):
    for i in os.listdir(path):
        if os.path.isdir(path+'/'+i):
            _isdir(path+'/'+i)
        x.append(path+'/'+i)    
def _exfile(file):
    if file[-4:]==ext:
        y.append(file)
def _file(file1):
    f=open(file1,'r')
    for i in f:
        if not i.find(key) == -1:
            z.append(file1)
    f.close()
_isdir(dirpath)
for i in x:
    _exfile(i)
for a in y:
    _file(a)
abc=set(z)
for i in abc:
    print i