Explorar o código

check_images.py understands common rand image syntax

lzlis %!s(int64=7) %!d(string=hai) anos
pai
achega
42816486c4
Modificáronse 1 ficheiros con 6 adicións e 1 borrados
  1. 6 1
      check_images.py

+ 6 - 1
check_images.py

@@ -24,7 +24,12 @@ for name in os.listdir("locations"):
     text = ifile.read()
     text = ifile.read()
     for match in re.finditer(r"images.+?[.](gif|jpg|png)", text, flags=re.U):
     for match in re.finditer(r"images.+?[.](gif|jpg|png)", text, flags=re.U):
         imgfile = match.group().encode("utf-8")
         imgfile = match.group().encode("utf-8")
-        images.append(imgfile)
+        randmatch = re.search(r"'\s*[+]\s*rand\s*[(]\s*(\d+)\s*[,]\s*(\d+)\s*[)]\s*[+]\s*'", imgfile)
+        if randmatch != None:
+            for i in range(int(randmatch.group(1)), 1+int(randmatch.group(2))):
+                images.append(re.sub(r"'\s*[+]\s*rand\s*[(].*?[)]\s*[+]\s*'", str(i), imgfile))
+        else:
+            images.append(imgfile)
     
     
     ifile.close()
     ifile.close()