summaryrefslogtreecommitdiff
path: root/passlib/ext
diff options
context:
space:
mode:
authorEli Collins <elic@assurancetechnologies.com>2013-12-27 14:10:07 -0500
committerEli Collins <elic@assurancetechnologies.com>2013-12-27 14:10:07 -0500
commit97216e14e96d5e8414946be29fe5f50673124d65 (patch)
tree71433321c66db55f7274bd2cf6410cfd1370be48 /passlib/ext
parentbcdf0cd2a97fa8dfb4cc06352faa0934ccbf236b (diff)
downloadpasslib-97216e14e96d5e8414946be29fe5f50673124d65.tar.gz
style cleanups (transplant of rc94c6072a652 in default)
Diffstat (limited to 'passlib/ext')
-rw-r--r--passlib/ext/django/models.py14
-rw-r--r--passlib/ext/django/utils.py20
2 files changed, 17 insertions, 17 deletions
diff --git a/passlib/ext/django/models.py b/passlib/ext/django/models.py
index a202c93..1c74f12 100644
--- a/passlib/ext/django/models.py
+++ b/passlib/ext/django/models.py
@@ -72,7 +72,7 @@ def _apply_patch():
from django.contrib.auth.models import UNUSABLE_PASSWORD
def is_password_usable(encoded):
- return encoded is not None and encoded != UNUSABLE_PASSWORD
+ return (encoded is not None and encoded != UNUSABLE_PASSWORD)
def is_valid_secret(secret):
return secret is not None
@@ -128,7 +128,7 @@ def _apply_patch():
#
@_manager.monkeypatch(USER_PATH)
def set_password(user, password):
- "passlib replacement for User.set_password()"
+ """passlib replacement for User.set_password()"""
if is_valid_secret(password):
# NOTE: pulls _get_category from module globals
cat = _get_category(user)
@@ -138,7 +138,7 @@ def _apply_patch():
@_manager.monkeypatch(USER_PATH)
def check_password(user, password):
- "passlib replacement for User.check_password()"
+ """passlib replacement for User.check_password()"""
hash = user.password
if not is_valid_secret(password) or not is_password_usable(hash):
return False
@@ -160,7 +160,7 @@ def _apply_patch():
@_manager.monkeypatch(HASHERS_PATH, enable=has_hashers)
@_manager.monkeypatch(MODELS_PATH)
def check_password(password, encoded, setter=None, preferred="default"):
- "passlib replacement for check_password()"
+ """passlib replacement for check_password()"""
# XXX: this currently ignores "preferred" keyword, since its purpose
# was for hash migration, and that's handled by the context.
if not is_valid_secret(password) or not is_password_usable(encoded):
@@ -178,7 +178,7 @@ def _apply_patch():
@_manager.monkeypatch(HASHERS_PATH)
@_manager.monkeypatch(MODELS_PATH)
def make_password(password, salt=None, hasher="default"):
- "passlib replacement for make_password()"
+ """passlib replacement for make_password()"""
if not is_valid_secret(password):
return make_unusable_password()
if hasher == "default":
@@ -197,7 +197,7 @@ def _apply_patch():
@_manager.monkeypatch(HASHERS_PATH)
@_manager.monkeypatch(FORMS_PATH)
def get_hasher(algorithm="default"):
- "passlib replacement for get_hasher()"
+ """passlib replacement for get_hasher()"""
if algorithm == "default":
scheme = None
else:
@@ -214,7 +214,7 @@ def _apply_patch():
@_manager.monkeypatch(HASHERS_PATH)
@_manager.monkeypatch(FORMS_PATH)
def identify_hasher(encoded):
- "passlib helper to identify hasher from encoded password"
+ """passlib helper to identify hasher from encoded password"""
handler = password_context.identify(encoded, resolve=True,
required=True)
algorithm = None
diff --git a/passlib/ext/django/utils.py b/passlib/ext/django/utils.py
index 1a05c14..e810998 100644
--- a/passlib/ext/django/utils.py
+++ b/passlib/ext/django/utils.py
@@ -123,14 +123,14 @@ DJANGO_PASSLIB_PREFIX = "django_"
_other_django_hashes = ["hex_md5"]
def passlib_to_hasher_name(passlib_name):
- "convert passlib handler name -> hasher name"
+ """convert passlib handler name -> hasher name"""
handler = get_crypt_handler(passlib_name)
if hasattr(handler, "django_name"):
return handler.django_name
return PASSLIB_HASHER_PREFIX + passlib_name
def hasher_to_passlib_name(hasher_name):
- "convert hasher name -> passlib handler name"
+ """convert hasher name -> passlib handler name"""
if hasher_name.startswith(PASSLIB_HASHER_PREFIX):
return hasher_name[len(PASSLIB_HASHER_PREFIX):]
if hasher_name == "unsalted_sha1":
@@ -252,7 +252,7 @@ def get_passlib_hasher(handler, algorithm=None):
return hasher
def _get_hasher(algorithm):
- "wrapper to call django.contrib.auth.hashers:get_hasher()"
+ """wrapper to call django.contrib.auth.hashers:get_hasher()"""
import sys
module = sys.modules.get("passlib.ext.django.models")
if module is None:
@@ -364,7 +364,7 @@ def _get_hasher(algorithm):
_UNSET = object()
class _PatchManager(object):
- "helper to manage monkeypatches and run sanity checks"
+ """helper to manage monkeypatches and run sanity checks"""
# NOTE: this could easily use a dict interface,
# but keeping it distinct to make clear that it's not a dict,
@@ -383,7 +383,7 @@ class _PatchManager(object):
__bool__ = __nonzero__ = lambda self: bool(self._state)
def _import_path(self, path):
- "retrieve obj and final attribute name from resource path"
+ """retrieve obj and final attribute name from resource path"""
name, attr = path.split(":")
obj = __import__(name, fromlist=[attr], level=0)
while '.' in attr:
@@ -393,7 +393,7 @@ class _PatchManager(object):
@staticmethod
def _is_same_value(left, right):
- "check if two values are the same (stripping method wrappers, etc)"
+ """check if two values are the same (stripping method wrappers, etc)"""
return get_method_function(left) == get_method_function(right)
#===================================================================
@@ -404,11 +404,11 @@ class _PatchManager(object):
return getattr(obj, attr, default)
def get(self, path, default=None):
- "return current value for path"
+ """return current value for path"""
return self._get_path(path, default)
def getorig(self, path, default=None):
- "return original (unpatched) value for path"
+ """return original (unpatched) value for path"""
try:
value, _= self._state[path]
except KeyError:
@@ -439,7 +439,7 @@ class _PatchManager(object):
setattr(obj, attr, value)
def patch(self, path, value):
- "monkeypatch object+attr at <path> to have <value>, stores original"
+ """monkeypatch object+attr at <path> to have <value>, stores original"""
assert value != _UNSET
current = self._get_path(path)
try:
@@ -461,7 +461,7 @@ class _PatchManager(object):
## self.patch(path, value)
def monkeypatch(self, parent, name=None, enable=True):
- "function decorator which patches function of same name in <parent>"
+ """function decorator which patches function of same name in <parent>"""
def builder(func):
if enable:
sep = "." if ":" in parent else ":"