check_images.py 908 B

123456789101112131415161718192021222324252627282930313233343536
  1. #!/usr/bin/env python
  2. import io
  3. import os
  4. import re
  5. import sys
  6. #path = os.getcwd()
  7. #print path
  8. startpattern = """mod/bratva/"""
  9. imgFormats = ['jpg','jpeg','gif','png','mp4']
  10. images = []
  11. ifile = io.open(
  12. "mod_bratva.txt",
  13. mode='rt',
  14. encoding='utf-16'
  15. )
  16. text = ifile.read()
  17. for match in re.finditer(r"mod/bratva/.+?[.](gif|jpg|jpeg|png|mp4)", text, flags=re.U):
  18. imgfile = match.group().encode("utf-8")
  19. randmatch = re.search(r"'\s*[+]\s*rand\s*[(]\s*(\d+)\s*[,]\s*(\d+)\s*[)]\s*[+]\s*'", imgfile)
  20. if randmatch != None:
  21. for i in range(int(randmatch.group(1)), 1+int(randmatch.group(2))):
  22. images.append(re.sub(r"'\s*[+]\s*rand\s*[(].*?[)]\s*[+]\s*'", str(i), imgfile))
  23. else:
  24. images.append(imgfile)
  25. ifile.close()
  26. for image in images:
  27. if not re.search(r"[<$]", image) and not os.path.isfile(image):
  28. print "Image not found:", image