#!/user/bin/env python
# -*- coding:utf-8 -*-
#grep -rl "python" D:\devtools\workspace\python\aaa
import os
def init(func):
def wrapper(*args,**kwargs):
res=func(*args,**kwargs)
res.send(None)
return res
return wrapper
@init
def search(target):
'找到文件的绝对路径'
while True:
dir_name=yield
g=os.walk(dir_name)
for i in g:
for j in i[-1]:
file_path="%s\\%s"%(i[0],j)
target.send(file_path)
@init
def get_file_handle(target):
'获取文件句柄'
while True:
file_path=yield
with open(file_path) as f:
target.send((file_path,f))
@init
def cat_file(target):
'读取文件'
while True:
file_path,f=yield
for line in f:
target.send((file_path,line))
@init
def printer(pattern):
'打印满足过滤条件的文件'
s=set()
while True:
file_path,line=yield
if pattern in line:
if file_path not in s:
print(file_path)
s.add(file_path)
g=search(get_file_handle(cat_file(printer("python"))))
g.send("D:\\devtools\\workspace\\python\\aaa")
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有