# HG changeset patch # User Xavier Glorot # Date 1269204348 14400 # Node ID 7800be7bce6618a047726db42ef48631efe6753a # Parent 716c99f4eb3a1c5eee88d1ebc21bfce57bcec038 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) diff -r 716c99f4eb3a -r 7800be7bce66 data_generation/transformations/pycaptcha/Captcha/File.py --- 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 # -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: diff -r 716c99f4eb3a -r 7800be7bce66 data_generation/transformations/ttf2jpg.py --- a/data_generation/transformations/ttf2jpg.py Wed Mar 17 16:41:51 2010 -0400 +++ b/data_generation/transformations/ttf2jpg.py Sun Mar 21 16:45:48 2010 -0400 @@ -10,6 +10,7 @@ import sys, os, fnmatch, random import Image, ImageFont, ImageDraw, numpy +import cPickle class ttf2jpg(): def __init__(self, font_file = ''): @@ -26,8 +27,9 @@ self.char_list.append(chr(ord('A') + i) ) for i in range(0,26): self.char_list.append(chr(ord('a') + i) ) - files = os.listdir(self.font_dir) - self.font_files = fnmatch.filter(files, '*.ttf') + fnmatch.filter(files, '*.TTF') + f = open( self.font_dir + 'filelist.pkl' ,'r') + self.font_files = cPickle.load(f) + f.close() # get font name def get_settings_names(self):