MediaWiki  1.29.1
captcha Namespace Reference

Functions

def gen_captcha (text, fontname, fontsize, file_name)
 
def gen_subdir (basedir, md5hash, levels)
 
def pick_word (words, blacklist, verbose, nwords, min_length, max_length)
 
def read_wordlist (filename)
 
def try_pick_word (words, blacklist, verbose, nwords, min_length, max_length)
 
def wobbly_copy (src, wob, col, scale, ang)
 

Variables

 action
 
 args
 
def blacklist = read_wordlist(opts.blacklist)
 
 count = opts.count
 
 default
 
 dirs = opts.dirs
 
string filename = "image_%s_%s.png" % (salt, md5hash)
 
 fill = opts.fill
 
 font = opts.font
 
 fontsize = opts.font_size
 
 help
 
 key = opts.key
 
 md5hash = hashlib.md5((key+salt+word+key+salt).encode('utf-8')).hexdigest()[:16]
 
 metavar
 
 nonalpha = re.compile('[^a-z]')
 
 opts
 
 output = opts.output
 
 parser = OptionParser()
 
string salt = "%08x" % random.randrange(2**32)
 
 script_dir = os.path.dirname(os.path.realpath(__file__))
 
def subdir = gen_subdir(output, md5hash, dirs)
 
 type
 
 verbose = opts.verbose
 
def word = pick_word(words, blacklist, verbose, opts.number_words, opts.min_length, opts.max_length)
 
 wordlist = opts.wordlist
 
 words = None
 

Function Documentation

◆ gen_captcha()

def captcha.gen_captcha (   text,
  fontname,
  fontsize,
  file_name 
)
Generate a captcha image

Definition at line 74 of file captcha.py.

References wobbly_copy().

◆ gen_subdir()

def captcha.gen_subdir (   basedir,
  md5hash,
  levels 
)
Generate a subdirectory path out of the first _levels_
characters of _hash_, and ensure the directories exist
under _basedir_.

Definition at line 128 of file captcha.py.

◆ pick_word()

def captcha.pick_word (   words,
  blacklist,
  verbose,
  nwords,
  min_length,
  max_length 
)

Definition at line 182 of file captcha.py.

References try_pick_word().

◆ read_wordlist()

def captcha.read_wordlist (   filename)

Definition at line 189 of file captcha.py.

References Makefile.open.

◆ try_pick_word()

def captcha.try_pick_word (   words,
  blacklist,
  verbose,
  nwords,
  min_length,
  max_length 
)

Definition at line 144 of file captcha.py.

Referenced by pick_word().

◆ wobbly_copy()

def captcha.wobbly_copy (   src,
  wob,
  col,
  scale,
  ang 
)

Definition at line 49 of file captcha.py.

Referenced by gen_captcha().

Variable Documentation

◆ action

captcha.action

Definition at line 206 of file captcha.py.

◆ args

captcha.args

Definition at line 220 of file captcha.py.

◆ blacklist

def captcha.blacklist = read_wordlist(opts.blacklist)

Definition at line 241 of file captcha.py.

◆ count

captcha.count = opts.count

Definition at line 242 of file captcha.py.

◆ default

captcha.default

Definition at line 210 of file captcha.py.

◆ dirs

captcha.dirs = opts.dirs

Definition at line 244 of file captcha.py.

◆ filename

captcha.filename = "image_%s_%s.png" % (salt, md5hash)

Definition at line 263 of file captcha.py.

◆ fill

captcha.fill = opts.fill

Definition at line 243 of file captcha.py.

◆ font

captcha.font = opts.font

Definition at line 237 of file captcha.py.

◆ fontsize

captcha.fontsize = opts.font_size

Definition at line 246 of file captcha.py.

◆ help

captcha.help

Definition at line 205 of file captcha.py.

◆ key

captcha.key = opts.key

Definition at line 229 of file captcha.py.

◆ md5hash

captcha.md5hash = hashlib.md5((key+salt+word+key+salt).encode('utf-8')).hexdigest()[:16]

Definition at line 262 of file captcha.py.

◆ metavar

captcha.metavar

Definition at line 205 of file captcha.py.

◆ nonalpha

captcha.nonalpha = re.compile('[^a-z]')

Definition at line 46 of file captcha.py.

◆ opts

captcha.opts

Definition at line 220 of file captcha.py.

◆ output

captcha.output = opts.output

Definition at line 233 of file captcha.py.

◆ parser

captcha.parser = OptionParser()

Definition at line 204 of file captcha.py.

◆ salt

string captcha.salt = "%08x" % random.randrange(2**32)

Definition at line 260 of file captcha.py.

◆ script_dir

captcha.script_dir = os.path.dirname(os.path.realpath(__file__))

Definition at line 203 of file captcha.py.

◆ subdir

def captcha.subdir = gen_subdir(output, md5hash, dirs)

Definition at line 265 of file captcha.py.

◆ type

captcha.type

Definition at line 210 of file captcha.py.

◆ verbose

captcha.verbose = opts.verbose

Definition at line 245 of file captcha.py.

◆ word

def captcha.word = pick_word(words, blacklist, verbose, opts.number_words, opts.min_length, opts.max_length)

Definition at line 259 of file captcha.py.

◆ wordlist

captcha.wordlist = opts.wordlist

Definition at line 223 of file captcha.py.

◆ words

list captcha.words = None

Definition at line 251 of file captcha.py.