From: Steven Tobin Date: Sat, 2 Jun 2012 22:25:50 +0000 (+0100) Subject: improved PEP8 compliance X-Git-Url: http://git.99rst.org/?a=commitdiff_plain;h=3d72498c0b5fcda7b0e7a17d9bacf49bc52b03c0;p=redacted-XKCD-password-generator.git improved PEP8 compliance --- diff --git a/xkcd-password.py b/xkcd-password.py index abf5450..c1917b4 100755 --- a/xkcd-password.py +++ b/xkcd-password.py @@ -8,7 +8,7 @@ All rights reserved. Contributors: Steven Tobin, Rob Lanphier, Mithrandir , - Daniel Beecham + Daniel Beecham Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -39,6 +39,7 @@ import optparse import re import math + # random.SystemRandom() should be cryptographically secure try: rng = random.SystemRandom @@ -49,7 +50,11 @@ except AttributeError: rng = random.Random -def generate_wordlist(wordfile=None, min_length=5, max_length=9, valid_chars='.'): + +def generate_wordlist(wordfile=None, + min_length=5, + max_length=9, + valid_chars='.'): """ generate a word list from either a kwarg word_file, or a system default valid_chars is a regular expression match condition (default - all chars) @@ -88,9 +93,11 @@ def report_entropy(length, numwords): """ bits = math.log(length, 2) if (int(bits) == bits): - print("Your word list contains %i words, or 2^%i words. " % (length, bits)) + print("Your word list contains %i words, or 2^%i words. " + % (length, bits)) else: - print("Your word list contains %i words, or 2^%0.2f words. " % (length, bits)) + print("Your word list contains %i words, or 2^%0.2f words. " + % (length, bits)) print("A %i word password from this list will have roughly" "%i (%0.2f * %i) bits of entropy," % @@ -122,6 +129,7 @@ def generate_xkcdpassword(wordlist, n_words=4, interactive=False): return passwd + if __name__ == '__main__': usage = "usage: %prog [options]"