mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-10-17 05:41:25 +02:00
Fix an issue with __metaclass__ in python3
improve code quality
This commit is contained in:
@@ -36,7 +36,7 @@ def get_dovecot_schemes():
|
||||
"""Return schemes supported by dovecot"""
|
||||
supported_schemes = None
|
||||
try:
|
||||
code, schemes = doveadm_cmd("pw -l")
|
||||
_, schemes = doveadm_cmd("pw -l")
|
||||
except OSError:
|
||||
pass
|
||||
else:
|
||||
|
||||
@@ -17,8 +17,27 @@ from random import Random
|
||||
from django.utils.crypto import constant_time_compare
|
||||
from django.utils.encoding import force_bytes, force_text
|
||||
|
||||
from six import with_metaclass
|
||||
|
||||
class PasswordHasher(object):
|
||||
|
||||
class MetaHasher(type):
|
||||
"""
|
||||
PasswordHasher Metaclass
|
||||
|
||||
Allow classmethod to be properties
|
||||
"""
|
||||
@property
|
||||
def name(cls):
|
||||
"""Returns the name of the hasher"""
|
||||
return cls.__name__.rstrip('Hasher').lower()
|
||||
|
||||
@property
|
||||
def label(cls):
|
||||
"""Returns the label of the hasher"""
|
||||
return cls.name if not cls._weak else "{} (weak)".format(cls.name)
|
||||
|
||||
|
||||
class PasswordHasher(with_metaclass(MetaHasher, object)):
|
||||
"""
|
||||
Base class of all hashers.
|
||||
"""
|
||||
@@ -27,16 +46,6 @@ class PasswordHasher(object):
|
||||
def __init__(self, target="local"):
|
||||
self._target = target
|
||||
|
||||
class __metaclass__(type):
|
||||
"""class properties"""
|
||||
@property
|
||||
def name(cls):
|
||||
return cls.__name__.rstrip('Hasher').lower()
|
||||
|
||||
@property
|
||||
def label(cls):
|
||||
return cls.name if not cls._weak else "{} (weak)".format(cls.name)
|
||||
|
||||
def _encrypt(self, clearvalue, salt=None):
|
||||
raise NotImplementedError
|
||||
|
||||
|
||||
@@ -46,7 +46,8 @@ def exec_cmd(cmd, sudo_user=None, pinput=None, capture_output=True, **kwargs):
|
||||
return process.returncode, output
|
||||
|
||||
|
||||
def doveadm_cmd(params, sudo_user=None, pinput=None, capture_output=True, **kwargs):
|
||||
def doveadm_cmd(params, sudo_user=None, pinput=None,
|
||||
capture_output=True, **kwargs):
|
||||
"""Execute doveadm command.
|
||||
|
||||
Run doveadm command using the current user. Set :keyword:`sudo_user` if
|
||||
|
||||
Reference in New Issue
Block a user