annotate pycaptcha/Facade.py @ 135:36010ff90255

Added script to test truetype font files validity (corruption)
author boulanni <nicolas_boulanger@hotmail.com>
date Sat, 20 Feb 2010 02:10:30 -0500
parents 66b9513b578f
children
rev   line source
87
4775b4195b4b code pour la generation de captchas
goldfinger
parents:
diff changeset
1 #!/usr/bin/env python
4775b4195b4b code pour la generation de captchas
goldfinger
parents:
diff changeset
2
4775b4195b4b code pour la generation de captchas
goldfinger
parents:
diff changeset
3
4775b4195b4b code pour la generation de captchas
goldfinger
parents:
diff changeset
4
4775b4195b4b code pour la generation de captchas
goldfinger
parents:
diff changeset
5 from Captcha.Visual.Tests import PseudoGimpy, AngryGimpy
4775b4195b4b code pour la generation de captchas
goldfinger
parents:
diff changeset
6 import numpy
4775b4195b4b code pour la generation de captchas
goldfinger
parents:
diff changeset
7
4775b4195b4b code pour la generation de captchas
goldfinger
parents:
diff changeset
8 # Une fonction simple pour generer un captcha
4775b4195b4b code pour la generation de captchas
goldfinger
parents:
diff changeset
9 # ease : represente la difficulte du captcha a generer
4775b4195b4b code pour la generation de captchas
goldfinger
parents:
diff changeset
10 # 0 = facile et 1 (ou autre chose) = difficile
4775b4195b4b code pour la generation de captchas
goldfinger
parents:
diff changeset
11 #solution : specifie si on veut en retour un array numpy representant
4775b4195b4b code pour la generation de captchas
goldfinger
parents:
diff changeset
12 #l image ou un tuple contenant l'array et la solution du captcha.
4775b4195b4b code pour la generation de captchas
goldfinger
parents:
diff changeset
13
4775b4195b4b code pour la generation de captchas
goldfinger
parents:
diff changeset
14 # Des fontes additionnelles peuvent etre ajoutees au dossier pyCaptcha/Captcha/data/fonts/others
4775b4195b4b code pour la generation de captchas
goldfinger
parents:
diff changeset
15 # Le programme choisit une fonte aleatoirement dans ce dossier ainsi que le dossir vera.
4775b4195b4b code pour la generation de captchas
goldfinger
parents:
diff changeset
16
4775b4195b4b code pour la generation de captchas
goldfinger
parents:
diff changeset
17
4775b4195b4b code pour la generation de captchas
goldfinger
parents:
diff changeset
18 def generateCaptcha (ease=0, solution=0):
4775b4195b4b code pour la generation de captchas
goldfinger
parents:
diff changeset
19
4775b4195b4b code pour la generation de captchas
goldfinger
parents:
diff changeset
20 if ease == 1:
4775b4195b4b code pour la generation de captchas
goldfinger
parents:
diff changeset
21 g = AngryGimpy()
4775b4195b4b code pour la generation de captchas
goldfinger
parents:
diff changeset
22
4775b4195b4b code pour la generation de captchas
goldfinger
parents:
diff changeset
23 else:
4775b4195b4b code pour la generation de captchas
goldfinger
parents:
diff changeset
24 g = PseudoGimpy()
4775b4195b4b code pour la generation de captchas
goldfinger
parents:
diff changeset
25
4775b4195b4b code pour la generation de captchas
goldfinger
parents:
diff changeset
26 i = g.render()
4775b4195b4b code pour la generation de captchas
goldfinger
parents:
diff changeset
27 a = numpy.asarray(i)
4775b4195b4b code pour la generation de captchas
goldfinger
parents:
diff changeset
28
4775b4195b4b code pour la generation de captchas
goldfinger
parents:
diff changeset
29 if solution == 0:
4775b4195b4b code pour la generation de captchas
goldfinger
parents:
diff changeset
30 return a
4775b4195b4b code pour la generation de captchas
goldfinger
parents:
diff changeset
31
4775b4195b4b code pour la generation de captchas
goldfinger
parents:
diff changeset
32 else :
126
66b9513b578f Fixed bug in pycaptcha/Facade.py
boulanni <nicolas_boulanger@hotmail.com>
parents: 87
diff changeset
33 return (a, g.solutions)