Guest User

Untitled

a guest
Apr 20th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. # genfind.py
  2. #
  3. # A function that generates files that match a given filename pattern
  4.  
  5. import os
  6. import fnmatch
  7.  
  8. def gen_find(filepat,top):
  9. for path, dirlist, filelist in os.walk(top):
  10. for name in fnmatch.filter(filelist,filepat):
  11. yield os.path.join(path,name)
  12.  
  13. # Example use
  14.  
  15. if __name__ == '__main__':
  16. lognames = gen_find("access-log*","www")
  17. for name in lognames:
  18. print name
Add Comment
Please, Sign In to add comment