You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 lines
853B

  1. #!/usr/bin/python
  2. import os
  3. import re
  4. def findfiles(path, regex):
  5. regObj = re.compile(regex)
  6. res = []
  7. for root, dirs, fnames in os.walk(path):
  8. for fname in fnames:
  9. #print fname
  10. if regObj.match(fname):
  11. res.append(os.path.join(root, fname))
  12. return res
  13. def grep(filepath, regex):
  14. regObj = re.compile(regex)
  15. res = []
  16. with open(filepath) as f:
  17. for line in f:
  18. #print line
  19. if re.search('addModel',line):
  20. m2 = re.findall(r'\"(.+?)\"',line)
  21. #res.append(line)
  22. if len(m2) > 1:
  23. print m2[0],"[",m2[1],"]"
  24. return res
  25. headers = findfiles('.', r'.*cpp$')
  26. #print headers
  27. for filepath in headers:
  28. # print filepath
  29. res = grep( filepath, r'.*addModel.*"(.*)",')
  30. #print res