[Python-modules-commits] [django-simple-captcha] 02/07: Import django-simple-captcha_0.4.6.orig.tar.gz

Brian May bam at moszumanska.debian.org
Thu Oct 22 01:34:42 UTC 2015


This is an automated email from the git hooks/post-receive script.

bam pushed a commit to branch master
in repository django-simple-captcha.

commit 5058ba3ccc0b922585223efee73540971cae6cd0
Author: Brian May <bam at debian.org>
Date:   Thu Oct 22 12:20:09 2015 +1100

    Import django-simple-captcha_0.4.6.orig.tar.gz
---
 .gitignore                                         |  10 +
 .pep8                                              |   3 +
 .travis.yml                                        |  22 +++
 CHANGES                                            |   6 +
 PKG-INFO                                           |  22 ---
 captcha/__init__.py                                |   2 +-
 captcha/locale/de/LC_MESSAGES/django.mo            | Bin 678 -> 675 bytes
 captcha/locale/de/LC_MESSAGES/django.po            |   6 +-
 captcha/models.py                                  |  24 +--
 captcha/tests/tests.py                             |  26 +++
 captcha/urls.py                                    |  19 +-
 captcha/views.py                                   |  15 +-
 django_simple_captcha.egg-info/PKG-INFO            |  22 ---
 django_simple_captcha.egg-info/SOURCES.txt         |  63 -------
 .../dependency_links.txt                           |   1 -
 django_simple_captcha.egg-info/not-zip-safe        |   1 -
 django_simple_captcha.egg-info/requires.txt        |   4 -
 django_simple_captcha.egg-info/top_level.txt       |   2 -
 docs/Makefile                                      |  89 +++++++++
 docs/_static/captcha3.png                          | Bin 0 -> 9633 bytes
 docs/_static/dict.png                              | Bin 0 -> 7859 bytes
 docs/_static/math.png                              | Bin 0 -> 7491 bytes
 docs/_static/random_chars.png                      | Bin 0 -> 8136 bytes
 docs/advanced.rst                                  | 202 +++++++++++++++++++++
 docs/conf.py                                       | 198 ++++++++++++++++++++
 docs/index.rst                                     |  41 +++++
 docs/usage.rst                                     | 143 +++++++++++++++
 setup.cfg                                          |   7 +-
 testproject/.coveragerc                            |  10 +
 testproject/__init__.py                            |   0
 testproject/coverage.sh                            |   5 +
 testproject/forms.py                               |   6 +
 testproject/manage.py                              |  26 +++
 testproject/settings.py                            |  61 +++++++
 testproject/settings_17.py                         |  61 +++++++
 testproject/templates/home.html                    |  12 ++
 testproject/urls.py                                |  10 +
 testproject/views.py                               |  17 ++
 tox.ini                                            |  66 +++++++
 39 files changed, 1052 insertions(+), 150 deletions(-)

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..4be0a97
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,10 @@
+dist
+*.pyc
+*.egg-info
+docs/_build/
+.venv*
+testproject/django-simple-captcha.db
+testproject/.coverage
+testproject/coverage.xml
+testproject/htmlcov/
+.tox
diff --git a/.pep8 b/.pep8
new file mode 100644
index 0000000..4ad0546
--- /dev/null
+++ b/.pep8
@@ -0,0 +1,3 @@
+[flake8]
+ignore = E501
+exclude = south_migrations,migrations,.venv_*,docs
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..d891a4c
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,22 @@
+language: python
+services: memcached
+python: 2.7
+env:
+  - TOX_ENV=py26-django14
+  - TOX_ENV=py27-django14
+  - TOX_ENV=py26-django15
+  - TOX_ENV=py27-django15
+  - TOX_ENV=py34-django15
+  - TOX_ENV=py26-django16
+  - TOX_ENV=py27-django16
+  - TOX_ENV=py34-django16
+  - TOX_ENV=py27-django17
+  - TOX_ENV=py34-django17
+  - TOX_ENV=py27-django18
+  - TOX_ENV=py34-django18
+  - TOX_ENV=flake8
+  - TOX_ENV=gettext
+install:
+  - pip install tox
+script:
+  - tox -e $TOX_ENV
diff --git a/CHANGES b/CHANGES
index 1cef442..7ecac93 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,9 @@
+Version 0.4.6
+-------------
+* Fixes an UnicodeDecodeError which was apparently only triggered during testing on TravisCI (I hope)
+* Support for Django 2.0 urlpatterns syntax (PR #82, Thanks @R3v1L)
+* settings.CAPTCHA_FONT_PATH may be a list, in which case a font is picked randomly (Issue #51 fixed in PR #88, Thanks @inflrscns)
+
 Version 0.4.5
 -------------
 * Test with tox
diff --git a/PKG-INFO b/PKG-INFO
deleted file mode 100644
index f54723f..0000000
--- a/PKG-INFO
+++ /dev/null
@@ -1,22 +0,0 @@
-Metadata-Version: 1.1
-Name: django-simple-captcha
-Version: 0.4.5
-Summary: A very simple, yet powerful, Django captcha application
-Home-page: https://github.com/mbi/django-simple-captcha
-Author: Marco Bonetti
-Author-email: mbonetti at gmail.com
-License: MIT
-Description: UNKNOWN
-Platform: UNKNOWN
-Classifier: Development Status :: 4 - Beta
-Classifier: Environment :: Web Environment
-Classifier: Intended Audience :: Developers
-Classifier: License :: OSI Approved :: MIT License
-Classifier: Operating System :: OS Independent
-Classifier: Programming Language :: Python
-Classifier: Programming Language :: Python :: 2.6
-Classifier: Programming Language :: Python :: 2.7
-Classifier: Programming Language :: Python :: 3.3
-Classifier: Topic :: Security
-Classifier: Topic :: Internet :: WWW/HTTP
-Classifier: Framework :: Django
diff --git a/captcha/__init__.py b/captcha/__init__.py
index db98bac..37a6f1b 100644
--- a/captcha/__init__.py
+++ b/captcha/__init__.py
@@ -1,6 +1,6 @@
 import re
 
-VERSION = (0, 4, 5)
+VERSION = (0, 4, 6)
 
 
 def get_version(svn=False):
diff --git a/captcha/locale/de/LC_MESSAGES/django.mo b/captcha/locale/de/LC_MESSAGES/django.mo
index b1801e1..7c8f63f 100644
Binary files a/captcha/locale/de/LC_MESSAGES/django.mo and b/captcha/locale/de/LC_MESSAGES/django.mo differ
diff --git a/captcha/locale/de/LC_MESSAGES/django.po b/captcha/locale/de/LC_MESSAGES/django.po
index 286ce65..0c446eb 100644
--- a/captcha/locale/de/LC_MESSAGES/django.po
+++ b/captcha/locale/de/LC_MESSAGES/django.po
@@ -20,13 +20,13 @@ msgstr ""
 
 #: fields.py:90
 msgid "Play CAPTCHA as audio file"
-msgstr "Spiel das CAPTCHA als Audiodatei ab."
+msgstr "CAPTCHA als Audiodatei abspielen."
 
 #: fields.py:105 fields.py:134 tests/tests.py:99 tests/tests.py:239
 #: tests/tests.py:246
 msgid "Invalid CAPTCHA"
-msgstr "Üngültiges CAPTCHA"
+msgstr "Ungültiges CAPTCHA"
 
 #: tests/tests.py:125
 msgid "This field is required."
-msgstr "Dieses Feld ist benötigt."
+msgstr "Dieses Feld wird benötigt."
diff --git a/captcha/models.py b/captcha/models.py
index c51f291..32c79ab 100644
--- a/captcha/models.py
+++ b/captcha/models.py
@@ -1,11 +1,12 @@
 from captcha.conf import settings as captcha_settings
 from django.db import models
 from django.conf import settings
+from django.utils.encoding import smart_text
 import datetime
 import random
 import time
-import unicodedata
-import six
+import hashlib
+
 
 # Heavily based on session key generation in Django
 # Use the system (hardware-based) random number generator if it exists.
@@ -16,13 +17,6 @@ else:
 MAX_RANDOM_KEY = 18446744073709551616     # 2 << 63
 
 
-try:
-    import hashlib  # sha for Python 2.5+
-except ImportError:
-    import sha  # sha for Python 2.4 (deprecated in Python 2.6)
-    hashlib = False
-
-
 def get_safe_now():
     try:
         from django.utils.timezone import utc
@@ -44,11 +38,13 @@ class CaptchaStore(models.Model):
         if not self.expiration:
             self.expiration = get_safe_now() + datetime.timedelta(minutes=int(captcha_settings.CAPTCHA_TIMEOUT))
         if not self.hashkey:
-            key_ = unicodedata.normalize('NFKD', str(randrange(0, MAX_RANDOM_KEY)) + str(time.time()) + six.text_type(self.challenge)).encode('ascii', 'ignore') + unicodedata.normalize('NFKD', six.text_type(self.response)).encode('ascii', 'ignore')
-            if hashlib:
-                self.hashkey = hashlib.sha1(key_).hexdigest()
-            else:
-                self.hashkey = sha.new(key_).hexdigest()
+            key_ = (
+                smart_text(randrange(0, MAX_RANDOM_KEY)) +
+                smart_text(time.time()) +
+                smart_text(self.challenge, errors='ignore') +
+                smart_text(self.response, errors='ignore')
+            ).encode('utf8')
+            self.hashkey = hashlib.sha1(key_).hexdigest()
             del(key_)
         super(CaptchaStore, self).save(*args, **kwargs)
 
diff --git a/captcha/tests/tests.py b/captcha/tests/tests.py
index c82f237..c240b62 100644
--- a/captcha/tests/tests.py
+++ b/captcha/tests/tests.py
@@ -331,6 +331,32 @@ class CaptchaCase(TestCase):
 
         settings.CAPTCHA_IMAGE_SIZE = __current_test_mode_setting
 
+    def test_multiple_fonts(self):
+        vera = os.path.join(os.path.dirname(__file__), '..', 'fonts', 'Vera.ttf')
+        __current_test_mode_setting = settings.CAPTCHA_FONT_PATH
+        settings.CAPTCHA_FONT_PATH = vera
+
+        for key in [store.hashkey for store in six.itervalues(self.stores)]:
+            response = self.client.get(reverse('captcha-image', kwargs=dict(key=key)))
+            self.assertEqual(response.status_code, 200)
+            self.assertEqual(response._headers.get('content-type'), ('Content-Type', 'image/png'))
+
+        settings.CAPTCHA_FONT_PATH = [vera, vera, vera]
+        for key in [store.hashkey for store in six.itervalues(self.stores)]:
+            response = self.client.get(reverse('captcha-image', kwargs=dict(key=key)))
+            self.assertEqual(response.status_code, 200)
+            self.assertEqual(response._headers.get('content-type'), ('Content-Type', 'image/png'))
+
+        settings.CAPTCHA_FONT_PATH = False
+        for key in [store.hashkey for store in six.itervalues(self.stores)]:
+            try:
+                response = self.client.get(reverse('captcha-image', kwargs=dict(key=key)))
+                self.fail()
+            except ImproperlyConfigured:
+                pass
+
+        settings.CAPTCHA_FONT_PATH = __current_test_mode_setting
+
 
 def trivial_challenge():
     return 'trivial', 'trivial'
diff --git a/captcha/urls.py b/captcha/urls.py
index 9bc9946..ab08ae6 100644
--- a/captcha/urls.py
+++ b/captcha/urls.py
@@ -1,12 +1,13 @@
 try:
-    from django.conf.urls import patterns, url
+    from django.conf.urls import url
 except ImportError:
-    from django.conf.urls.defaults import patterns, url
+    from django.conf.urls.defaults import url
 
-urlpatterns = patterns(
-    'captcha.views',
-    url(r'image/(?P<key>\w+)/$', 'captcha_image', name='captcha-image', kwargs={'scale': 1}),
-    url(r'image/(?P<key>\w+)@2/$', 'captcha_image', name='captcha-image-2x', kwargs={'scale': 2}),
-    url(r'audio/(?P<key>\w+)/$', 'captcha_audio', name='captcha-audio'),
-    url(r'refresh/$', 'captcha_refresh', name='captcha-refresh'),
-)
+from captcha import views
+
+urlpatterns = [
+    url(r'image/(?P<key>\w+)/$', views.captcha_image, name='captcha-image', kwargs={'scale': 1}),
+    url(r'image/(?P<key>\w+)@2/$', views.captcha_image, name='captcha-image-2x', kwargs={'scale': 2}),
+    url(r'audio/(?P<key>\w+)/$', views.captcha_audio, name='captcha-audio'),
+    url(r'refresh/$', views.captcha_refresh, name='captcha-refresh'),
+]
diff --git a/captcha/views.py b/captcha/views.py
index df1aa36..c3517de 100644
--- a/captcha/views.py
+++ b/captcha/views.py
@@ -2,11 +2,13 @@ from captcha.conf import settings
 from captcha.helpers import captcha_image_url
 from captcha.models import CaptchaStore
 from django.http import HttpResponse, Http404
+from django.core.exceptions import ImproperlyConfigured
 import random
 import re
 import tempfile
 import os
 import subprocess
+import six
 
 try:
     from cStringIO import StringIO
@@ -54,10 +56,17 @@ def captcha_image(request, key, scale=1):
 
     text = store.challenge
 
-    if settings.CAPTCHA_FONT_PATH.lower().strip().endswith('ttf'):
-        font = ImageFont.truetype(settings.CAPTCHA_FONT_PATH, settings.CAPTCHA_FONT_SIZE * scale)
+    if isinstance(settings.CAPTCHA_FONT_PATH, six.string_types):
+        fontpath = settings.CAPTCHA_FONT_PATH
+    elif isinstance(settings.CAPTCHA_FONT_PATH, (list, tuple)):
+        fontpath = random.choice(settings.CAPTCHA_FONT_PATH)
     else:
-        font = ImageFont.load(settings.CAPTCHA_FONT_PATH)
+        raise ImproperlyConfigured('settings.CAPTCHA_FONT_PATH needs to be a path to a font or list of paths to fonts')
+
+    if fontpath.lower().strip().endswith('ttf'):
+        font = ImageFont.truetype(fontpath, settings.CAPTCHA_FONT_SIZE * scale)
+    else:
+        font = ImageFont.load(fontpath)
 
     if settings.CAPTCHA_IMAGE_SIZE:
         size = settings.CAPTCHA_IMAGE_SIZE
diff --git a/django_simple_captcha.egg-info/PKG-INFO b/django_simple_captcha.egg-info/PKG-INFO
deleted file mode 100644
index f54723f..0000000
--- a/django_simple_captcha.egg-info/PKG-INFO
+++ /dev/null
@@ -1,22 +0,0 @@
-Metadata-Version: 1.1
-Name: django-simple-captcha
-Version: 0.4.5
-Summary: A very simple, yet powerful, Django captcha application
-Home-page: https://github.com/mbi/django-simple-captcha
-Author: Marco Bonetti
-Author-email: mbonetti at gmail.com
-License: MIT
-Description: UNKNOWN
-Platform: UNKNOWN
-Classifier: Development Status :: 4 - Beta
-Classifier: Environment :: Web Environment
-Classifier: Intended Audience :: Developers
-Classifier: License :: OSI Approved :: MIT License
-Classifier: Operating System :: OS Independent
-Classifier: Programming Language :: Python
-Classifier: Programming Language :: Python :: 2.6
-Classifier: Programming Language :: Python :: 2.7
-Classifier: Programming Language :: Python :: 3.3
-Classifier: Topic :: Security
-Classifier: Topic :: Internet :: WWW/HTTP
-Classifier: Framework :: Django
diff --git a/django_simple_captcha.egg-info/SOURCES.txt b/django_simple_captcha.egg-info/SOURCES.txt
deleted file mode 100644
index 1f201c7..0000000
--- a/django_simple_captcha.egg-info/SOURCES.txt
+++ /dev/null
@@ -1,63 +0,0 @@
-CHANGES
-LICENSE
-MANIFEST.in
-README.rst
-setup.py
-captcha/__init__.py
-captcha/fields.py
-captcha/helpers.py
-captcha/models.py
-captcha/urls.py
-captcha/views.py
-captcha/conf/__init__.py
-captcha/conf/settings.py
-captcha/fonts/COPYRIGHT.TXT
-captcha/fonts/README.TXT
-captcha/fonts/Vera.ttf
-captcha/locale/bg/LC_MESSAGES/django.mo
-captcha/locale/bg/LC_MESSAGES/django.po
-captcha/locale/cs/LC_MESSAGES/django.mo
-captcha/locale/cs/LC_MESSAGES/django.po
-captcha/locale/de/LC_MESSAGES/django.mo
-captcha/locale/de/LC_MESSAGES/django.po
-captcha/locale/es/LC_MESSAGES/django.mo
-captcha/locale/es/LC_MESSAGES/django.po
-captcha/locale/fr/LC_MESSAGES/django.mo
-captcha/locale/fr/LC_MESSAGES/django.po
-captcha/locale/it/LC_MESSAGES/django.mo
-captcha/locale/it/LC_MESSAGES/django.po
-captcha/locale/ja/LC_MESSAGES/django.mo
-captcha/locale/ja/LC_MESSAGES/django.po
-captcha/locale/nl/LC_MESSAGES/django.mo
-captcha/locale/nl/LC_MESSAGES/django.po
-captcha/locale/pl/LC_MESSAGES/django.mo
-captcha/locale/pl/LC_MESSAGES/django.po
-captcha/locale/pt_BR/LC_MESSAGES/django.mo
-captcha/locale/pt_BR/LC_MESSAGES/django.po
-captcha/locale/ru/LC_MESSAGES/django.mo
-captcha/locale/ru/LC_MESSAGES/django.po
-captcha/locale/sk/LC_MESSAGES/django.mo
-captcha/locale/sk/LC_MESSAGES/django.po
-captcha/locale/tr/LC_MESSAGES/django.mo
-captcha/locale/tr/LC_MESSAGES/django.po
-captcha/locale/uk/LC_MESSAGES/django.mo
-captcha/locale/uk/LC_MESSAGES/django.po
-captcha/locale/zh_CN/LC_MESSAGES/django.mo
-captcha/locale/zh_CN/LC_MESSAGES/django.po
-captcha/management/__init__.py
-captcha/management/commands/__init__.py
-captcha/management/commands/captcha_clean.py
-captcha/migrations/0001_initial.py
-captcha/migrations/__init__.py
-captcha/south_migrations/0001_initial.py
-captcha/south_migrations/__init__.py
-captcha/tests/__init__.py
-captcha/tests/tests.py
-captcha/tests/urls.py
-captcha/tests/views.py
-django_simple_captcha.egg-info/PKG-INFO
-django_simple_captcha.egg-info/SOURCES.txt
-django_simple_captcha.egg-info/dependency_links.txt
-django_simple_captcha.egg-info/not-zip-safe
-django_simple_captcha.egg-info/requires.txt
-django_simple_captcha.egg-info/top_level.txt
\ No newline at end of file
diff --git a/django_simple_captcha.egg-info/dependency_links.txt b/django_simple_captcha.egg-info/dependency_links.txt
deleted file mode 100644
index 8b13789..0000000
--- a/django_simple_captcha.egg-info/dependency_links.txt
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/django_simple_captcha.egg-info/not-zip-safe b/django_simple_captcha.egg-info/not-zip-safe
deleted file mode 100644
index 8b13789..0000000
--- a/django_simple_captcha.egg-info/not-zip-safe
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/django_simple_captcha.egg-info/requires.txt b/django_simple_captcha.egg-info/requires.txt
deleted file mode 100644
index ace60f9..0000000
--- a/django_simple_captcha.egg-info/requires.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-setuptools
-six >=1.2.0
-Django >= 1.4
-Pillow >=2.2.2
diff --git a/django_simple_captcha.egg-info/top_level.txt b/django_simple_captcha.egg-info/top_level.txt
deleted file mode 100644
index d941b23..0000000
--- a/django_simple_captcha.egg-info/top_level.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-captcha
-testproject
diff --git a/docs/Makefile b/docs/Makefile
new file mode 100644
index 0000000..338297f
--- /dev/null
+++ b/docs/Makefile
@@ -0,0 +1,89 @@
+# Makefile for Sphinx documentation
+#
+
+# You can set these variables from the command line.
+SPHINXOPTS    =
+SPHINXBUILD   = sphinx-build
+PAPER         =
+BUILDDIR      = _build
+
+# Internal variables.
+PAPEROPT_a4     = -D latex_paper_size=a4
+PAPEROPT_letter = -D latex_paper_size=letter
+ALLSPHINXOPTS   = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
+
+.PHONY: help clean html dirhtml pickle json htmlhelp qthelp latex changes linkcheck doctest
+
+help:
+	@echo "Please use \`make <target>' where <target> is one of"
+	@echo "  html      to make standalone HTML files"
+	@echo "  dirhtml   to make HTML files named index.html in directories"
+	@echo "  pickle    to make pickle files"
+	@echo "  json      to make JSON files"
+	@echo "  htmlhelp  to make HTML files and a HTML help project"
+	@echo "  qthelp    to make HTML files and a qthelp project"
+	@echo "  latex     to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
+	@echo "  changes   to make an overview of all changed/added/deprecated items"
+	@echo "  linkcheck to check all external links for integrity"
+	@echo "  doctest   to run all doctests embedded in the documentation (if enabled)"
+
+clean:
+	-rm -rf $(BUILDDIR)/*
+
+html:
+	$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
+	@echo
+	@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
+
+dirhtml:
+	$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
+	@echo
+	@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
+
+pickle:
+	$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
+	@echo
+	@echo "Build finished; now you can process the pickle files."
+
+json:
+	$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
+	@echo
+	@echo "Build finished; now you can process the JSON files."
+
+htmlhelp:
+	$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
+	@echo
+	@echo "Build finished; now you can run HTML Help Workshop with the" \
+	      ".hhp project file in $(BUILDDIR)/htmlhelp."
+
+qthelp:
+	$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
+	@echo
+	@echo "Build finished; now you can run "qcollectiongenerator" with the" \
+	      ".qhcp project file in $(BUILDDIR)/qthelp, like this:"
+	@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/DjangoSimpleCaptcha.qhcp"
+	@echo "To view the help file:"
+	@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/DjangoSimpleCaptcha.qhc"
+
+latex:
+	$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
+	@echo
+	@echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
+	@echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \
+	      "run these through (pdf)latex."
+
+changes:
+	$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
+	@echo
+	@echo "The overview file is in $(BUILDDIR)/changes."
+
+linkcheck:
+	$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
+	@echo
+	@echo "Link check complete; look for any errors in the above output " \
+	      "or in $(BUILDDIR)/linkcheck/output.txt."
+
+doctest:
+	$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
+	@echo "Testing of doctests in the sources finished, look at the " \
+	      "results in $(BUILDDIR)/doctest/output.txt."
diff --git a/docs/_static/captcha3.png b/docs/_static/captcha3.png
new file mode 100644
index 0000000..7d2b9f9
Binary files /dev/null and b/docs/_static/captcha3.png differ
diff --git a/docs/_static/dict.png b/docs/_static/dict.png
new file mode 100644
index 0000000..9458460
Binary files /dev/null and b/docs/_static/dict.png differ
diff --git a/docs/_static/math.png b/docs/_static/math.png
new file mode 100644
index 0000000..ed123d9
Binary files /dev/null and b/docs/_static/math.png differ
diff --git a/docs/_static/random_chars.png b/docs/_static/random_chars.png
new file mode 100644
index 0000000..b431427
Binary files /dev/null and b/docs/_static/random_chars.png differ
diff --git a/docs/advanced.rst b/docs/advanced.rst
new file mode 100644
index 0000000..799200b
--- /dev/null
+++ b/docs/advanced.rst
@@ -0,0 +1,202 @@
+Advanced topics
+===============
+
+Configuration toggles
++++++++++++++++++++++
+
+The following configuration elements can be defined (in your ``settings.py``)
+
+CAPTCHA_FONT_PATH
+-----------------
+
+Full path and filename of a TrueType (TTF), OpenType, or pilfont font file used to render text.
+
+Defaults to: ``fonts/Vera.ttf`` (included in the application, GPL font).
+
+Note that your PIL installation must support TTF and/or OpenFont if you want to use these kind of glyphs (most modern distributions of PIL do.)
+
+Note: as of version 0.4.6, ``CAPTCHA_FONT_PATH`` may be an iterable of font paths, in which case a font will be picked randomly from the list for each CAPTCHA.
+
+CAPTCHA_FONT_SIZE
+-----------------
+
+Font-size in pixels of the rendered text.
+
+Defaults to '22'.
+
+CAPTCHA_IMAGE_SIZE
+------------------
+
+Image size in pixels of generated captcha, specified by 2-tuple (width, height)
+
+Defaults to `None` (automatically calculated)
+
+CAPTCHA_LETTER_ROTATION
+-----------------------
+
+A random rotation in this interval is applied to each letter in the challenge text.
+
+Defaults to ``(-35,35)``.
+
+New in version 0.1.6: set this to None to disable letter roation.
+
+CAPTCHA_BACKGROUND_COLOR
+------------------------
+
+Background-color of the captcha. Can be expressed as html-style #rrggbb, rgb(red, green, blue), or common html names (e.g. "red").
+
+Defaults to: ``'#ffffff'``
+
+CAPTCHA_FOREGROUND_COLOR
+------------------------
+
+Foreground-color of the captcha.
+
+Defaults to ``'#001100'``
+
+CAPTCHA_CHALLENGE_FUNCT
+------------------------
+
+String representing a python callable (i.e. a function) to use as challenge generator.
+
+See Generators below for a list of available generators and a guide on how to write your own.
+
+Defaults to: ``'captcha.helpers.random_char_challenge'``
+
+CAPTCHA_NOISE_FUNCTIONS
+------------------------
+
+List of strings of python callables that take a PIL ``DrawImage`` object and an ``Image`` image as input, modify the ``DrawImage``, then return it.
+
+Defaults to: ``('captcha.helpers.noise_arcs','captcha.helpers.noise_dots',)``
+
+A null noise helper function useful when debugging issues is available at ``'captcha.helpers.noise_null'``.
+
+
+CAPTCHA_FILTER_FUNCTIONS
+------------------------
+
+List of strings of python callables that take a PIL ``Image`` object as input, modify it and return it.
+
+These are called right before the rendering, i.e. after the noise functions.
+
+Defaults to: ``('captcha.helpers.post_smooth',)``
+
+
+CAPTCHA_WORDS_DICTIONARY
+------------------------
+
+Required for the ``word_challenge`` challenge function only. Points a file containing a list of words, one per line.
+
+Defaults to: ``'/usr/share/dict/words'``
+
+CAPTCHA_FLITE_PATH
+------------------------
+
+Full path to the ``flite`` executable. When defined, will automatically add audio output to the captcha.
+
+Defaults to: ``None`` (no audio output)
+
+CAPTCHA_TIMEOUT
+---------------
+
+Integer. Lifespan, in minutes, of the generated captcha.
+
+Defaults to: 5
+
+CAPTCHA_LENGTH
+------------------------
+
+Sets the length, in chars, of the generated captcha. (for the ``'captcha.helpers.random_char_challenge'`` challenge)
+
+Defaults to: 4
+
+CAPTCHA_DICTIONARY_MIN_LENGTH
+-----------------------------
+
+When using the word_challenge challenge function, controls the minimum length of the words to be randomly picked from the dictionary file.
+
+Defaults to: 0
+
+CAPTCHA_DICTIONARY_MAX_LENGTH
+-----------------------------
+
+When using the word_challenge challenge function, controls the maximal length of the words to be randomly picked from the dictionary file.
+
+Defaults to: 99
+
+Note: it's perfectly safe to specify e.g. ``CAPTCHA_DICTIONARY_MIN_LENGTH = CAPTCHA_DICTIONARY_MAX_LENGTH = 6`` but it's considered an error to define ``CAPTCHA_DICTIONARY_MAX_LENGTH`` to be smaller than ``CAPTCHA_DICTIONARY_MIN_LENGTH``.
+
+.. _output_format_ref:
+
+CAPTCHA_OUTPUT_FORMAT
+------------------------
+
+New in version 0.1.6
+
+Specify your own output format for the generated markup, when e.g. you want to position the captcha image relative to the text field in your form.
+
+Defaults to: ``u'%(image)s %(hidden_field)s %(text_field)s'``
+
+Note: the three keys have to be present in the format string or an error will be thrown at runtime.
+
+CAPTCHA_TEST_MODE
+------------------------
+
+New in version 0.3.6
+
+When set to True, the string "PASSED" (any case) will be accepted as a valid response to any CAPTCHA.
+Use this for testing purposes. Warning: do NOT set this to True in production.
+
+Defaults to: False
+
+
+Generators and modifiers
+++++++++++++++++++++++++
+
+Random chars
+------------
+
+.. image:: _static/random_chars.png
+
+Classic captcha that picks four random chars. This is case insensitive. ::
+
+    CAPTCHA_CHALLENGE_FUNCT = 'captcha.helpers.random_char_challenge'
+
+
+Simple Math
+------------
+
+.. image:: _static/math.png
+
+Another classic, that challenges the user to resolve a simple math challenge by randomly picking two numbers between one and nine, and a random operator among plus, minus, times. ::
+
+    CAPTCHA_CHALLENGE_FUNCT = 'captcha.helpers.math_challenge'
+
+
+Dictionary Word
+----------------
+
+.. image:: _static/dict.png
+
+Picks a random word from a dictionary file. Note, you must define ``CAPTCHA_WORDS_DICTIONARY`` in your cofiguration to use this generator. ::
+
+    CAPTCHA_CHALLENGE_FUNCT = 'captcha.helpers.word_challenge'
+
+
+Roll your own
+-------------
+
+To have your own challenge generator, simply point ``CAPTCHA_CHALLENGE_FUNCT`` to a function that returns a tuple of strings: the first one (the challenge) will be rendered in the captcha, the second is the valid response to the challenge, e.g. ``('5+10=', '15')``, ``('AAAA', 'aaaa')``
+
+This sample generator that returns six random digits::
+
+    import random
+
+    def random_digit_challenge():
+        ret = u''
+        for i in range(6):
+            ret += str(random.randint(0,9))
+        return ret, ret
+
+
diff --git a/docs/conf.py b/docs/conf.py
new file mode 100644
index 0000000..768da72
--- /dev/null
+++ b/docs/conf.py
@@ -0,0 +1,198 @@
+# -*- coding: utf-8 -*-
+#
+# Django Simple Captcha documentation build configuration file, created by
+# sphinx-quickstart on Sun Jul 10 12:35:54 2011.
+#
+# This file is execfile()d with the current directory set to its containing dir.
+#
+# Note that not all possible configuration values are present in this
+# autogenerated file.
+#
+# All configuration values have a default; values that are commented out
+# serve to show the default.
+
+import sys, os
+from six import u
+#sys.path.insert(0, '..')
+#import captcha
+#print captcha.get_version()
+
+# If extensions (or modules to document with autodoc) are in another directory,
+# add these directories to sys.path here. If the directory is relative to the
+# documentation root, use os.path.abspath to make it absolute, like shown here.
+#sys.path.append(os.path.abspath('.'))
+
+# -- General configuration -----------------------------------------------------
+
+# Add any Sphinx extension module names here, as strings. They can be extensions
+# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
+extensions = []
+
+# Add any paths that contain templates here, relative to this directory.
+templates_path = ['_templates']
+
+# The suffix of source filenames.
+source_suffix = '.rst'
+
+# The encoding of source files.
+#source_encoding = 'utf-8'
+
+# The master toctree document.
+master_doc = 'index'
+
+# General information about the project.
+project = u('Django Simple Captcha')
+copyright = u('2011-2015 Marco Bonetti')
+
+# The version info for the project you're documenting, acts as replacement for
+# |version| and |release|, also used in various other places throughout the
+# built documents.
+#
+# The short X.Y version.
+version = '0.4.6'
+# The full version, including alpha/beta/rc tags.
+release = '0.4.6'
+
+# The language for content autogenerated by Sphinx. Refer to documentation
+# for a list of supported languages.
+#language = None
+
+# There are two options for replacing |today|: either, you set today to some
+# non-false value, then it is used:
+#today = ''
+# Else, today_fmt is used as the format for a strftime call.
+#today_fmt = '%B %d, %Y'
+
+# List of documents that shouldn't be included in the build.
+#unused_docs = []
+
+# List of directories, relative to source directory, that shouldn't be searched
+# for source files.
+exclude_trees = ['_build']
+
+# The reST default role (used for this markup: `text`) to use for all documents.
+#default_role = None
+
+# If true, '()' will be appended to :func: etc. cross-reference text.
+#add_function_parentheses = True
+
+# If true, the current module name will be prepended to all description
+# unit titles (such as .. function::).
+#add_module_names = True
+
+# If true, sectionauthor and moduleauthor directives will be shown in the
+# output. They are ignored by default.
+#show_authors = False
+
+# The name of the Pygments (syntax highlighting) style to use.
+pygments_style = 'sphinx'
+
+# A list of ignored prefixes for module index sorting.
+#modindex_common_prefix = []
+
+
+# -- Options for HTML output ---------------------------------------------------
+
+# The theme to use for HTML and HTML Help pages.  Major themes that come with
+# Sphinx are currently 'default' and 'sphinxdoc'.
+html_theme = 'default'
+
+# Theme options are theme-specific and customize the look and feel of a theme
+# further.  For a list of options available for each theme, see the
+# documentation.
+#html_theme_options = {}
+
+# Add any paths that contain custom themes here, relative to this directory.
+#html_theme_path = []
+
+# The name for this set of Sphinx documents.  If None, it defaults to
+# "<project> v<release> documentation".
+#html_title = None
+
+# A shorter title for the navigation bar.  Default is the same as html_title.
+#html_short_title = None
+
+# The name of an image file (relative to this directory) to place at the top
+# of the sidebar.
+#html_logo = None
+
+# The name of an image file (within the static path) to use as favicon of the
+# docs.  This file should be a Windows icon file (.ico) being 16x16 or 32x32
+# pixels large.
+#html_favicon = None
+
+# Add any paths that contain custom static files (such as style sheets) here,
+# relative to this directory. They are copied after the builtin static files,
+# so a file named "default.css" will overwrite the builtin "default.css".
+html_static_path = ['_static']
+
+# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
+# using the given strftime format.
+#html_last_updated_fmt = '%b %d, %Y'
+
+# If true, SmartyPants will be used to convert quotes and dashes to
+# typographically correct entities.
+#html_use_smartypants = True
+
+# Custom sidebar templates, maps document names to template names.
+#html_sidebars = {}
+
+# Additional templates that should be rendered to pages, maps page names to
+# template names.
+#html_additional_pages = {}
+
+# If false, no module index is generated.
+#html_use_modindex = True
+
+# If false, no index is generated.
+#html_use_index = True
+
+# If true, the index is split into individual pages for each letter.
+#html_split_index = False
+
+# If true, links to the reST sources are added to the pages.
+#html_show_sourcelink = True
+
+# If true, an OpenSearch description file will be output, and all pages will
+# contain a <link> tag referring to it.  The value of this option must be the
+# base URL from which the finished HTML is served.
+#html_use_opensearch = ''
+
+# If nonempty, this is the file name suffix for HTML files (e.g. ".xhtml").
+#html_file_suffix = ''
+
+# Output file base name for HTML help builder.
+htmlhelp_basename = 'DjangoSimpleCaptchadoc'
+
+
+# -- Options for LaTeX output --------------------------------------------------
+
+# The paper size ('letter' or 'a4').
+#latex_paper_size = 'letter'
+
+# The font size ('10pt', '11pt' or '12pt').
+#latex_font_size = '10pt'
+
+# Grouping the document tree into LaTeX files. List of tuples
+# (source start file, target name, title, author, documentclass [howto/manual]).
+latex_documents = [
+  ('index', 'DjangoSimpleCaptcha.tex', u('Django Simple Captcha Documentation'),
+   u('Marco Bonetti'), 'manual'),
+]
+
+# The name of an image file (relative to this directory) to place at the top of
+# the title page.
+#latex_logo = None
+
+# For "manual" documents, if this is true, then toplevel headings are parts,
+# not chapters.
+#latex_use_parts = False
+
+# Additional stuff for the LaTeX preamble.
+#latex_preamble = ''
+
+# Documents to append as an appendix to all manuals.
+#latex_appendices = []
+
+# If false, no module index is generated.
+#latex_use_modindex = True
diff --git a/docs/index.rst b/docs/index.rst
new file mode 100644
index 0000000..d9eb069
--- /dev/null
+++ b/docs/index.rst
@@ -0,0 +1,41 @@
+*********************
+Django Simple Captcha
+*********************
+
+.. image:: https://travis-ci.org/mbi/django-simple-captcha.png?branch=master
+
+Django Simple Captcha is an extremely simple, yet highly customizable Django application to add captcha images to any Django form.
+
... 532 lines suppressed ...

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/django-simple-captcha.git



More information about the Python-modules-commits mailing list