diff data_generation/transformations/pycaptcha/Captcha/File.py @ 273:7800be7bce66

changes in ttf2jpg and pycaptcha to load a file list with cPickle (instead of doing a listdir()) in order to have always the same list order from different machine (to reproduce generation)
author Xavier Glorot <glorotxa@iro.umontreal.ca>
date Sun, 21 Mar 2010 16:45:48 -0400
parents 81f8466dc121
children
line wrap: on
line diff
--- a/data_generation/transformations/pycaptcha/Captcha/File.py	Wed Mar 17 16:41:51 2010 -0400
+++ b/data_generation/transformations/pycaptcha/Captcha/File.py	Sun Mar 21 16:45:48 2010 -0400
@@ -7,7 +7,7 @@
 # Copyright (C) 2004 Micah Dowty <micah@navi.cx>
 #
 
-import os, random
+import os, random, cPickle
 
 # Determine the data directory. This can be overridden after import-time if needed.
 dataDir = os.path.join(os.path.split(os.path.abspath(__file__))[0], "data")
@@ -41,7 +41,10 @@
             else:
                 path = os.path.join(dataDir, self.basePath, name)
             if os.path.isdir(path):
-                for content in os.listdir(path):
+                f = open(path + '/filelist.pkl')
+                filelist = cPickle.load(f)
+                f.close()
+                for content in filelist:
                     if self._checkExtension(content):
                         paths.append(os.path.join(path, content))
             else: