comparison 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
comparison
equal deleted inserted replaced
262:716c99f4eb3a 273:7800be7bce66
5 # 5 #
6 # PyCAPTCHA Package 6 # PyCAPTCHA Package
7 # Copyright (C) 2004 Micah Dowty <micah@navi.cx> 7 # Copyright (C) 2004 Micah Dowty <micah@navi.cx>
8 # 8 #
9 9
10 import os, random 10 import os, random, cPickle
11 11
12 # Determine the data directory. This can be overridden after import-time if needed. 12 # Determine the data directory. This can be overridden after import-time if needed.
13 dataDir = os.path.join(os.path.split(os.path.abspath(__file__))[0], "data") 13 dataDir = os.path.join(os.path.split(os.path.abspath(__file__))[0], "data")
14 14
15 15
39 if name[0] == '/': 39 if name[0] == '/':
40 path = name 40 path = name
41 else: 41 else:
42 path = os.path.join(dataDir, self.basePath, name) 42 path = os.path.join(dataDir, self.basePath, name)
43 if os.path.isdir(path): 43 if os.path.isdir(path):
44 for content in os.listdir(path): 44 f = open(path + '/filelist.pkl')
45 filelist = cPickle.load(f)
46 f.close()
47 for content in filelist:
45 if self._checkExtension(content): 48 if self._checkExtension(content):
46 paths.append(os.path.join(path, content)) 49 paths.append(os.path.join(path, content))
47 else: 50 else:
48 paths.append(path) 51 paths.append(path)
49 return paths 52 return paths