Advertisement
MGafi

Untitled

Nov 18th, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.50 KB | None | 0 0
  1. import sys
  2. import os
  3.  
  4. key=sys.argv[1]
  5. arg_path=sys.argv[2]
  6. option=sys.argv[3]
  7.  
  8. def functie(path1):
  9.     list1 = os.listdir(path1)
  10.     for entry in list1:
  11.         full_path = os.path.join(path1,entry)
  12.         if os.path.isdir(full_path):
  13.             functie(full_path)
  14.         else:
  15.             if option == "name":
  16.                 if key in entry:
  17.                     print(full_path)
  18.             else:
  19.                 file = open(full_path,'r') 
  20.                 filelist = file.read()
  21.                 file.close()
  22.                 if key in filelist:
  23.                     print(full_path)   
  24.  
  25. functie(os.path.abspath(arg_path))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement