PEP8 fixes

This commit is contained in:
Antoine Nguyen
2015-01-16 10:31:35 +01:00
parent 38649a614f
commit 0a49b0a52b
9 changed files with 34 additions and 11 deletions
+1
View File
@@ -9,6 +9,7 @@ from django.template import Context, Template
class Command(object):
"""Base command class
A valid administrative command must inherit from this class.
+8 -4
View File
@@ -1,18 +1,22 @@
# coding: utf-8
"""postfix_maps command."""
import datetime
import getpass
import inspect
import os
import sys
import datetime
from django.template import Context, Template
from . import Command
class MapFilesGenerator(object):
def __init__(self, dbinfo=None):
"""Constructor.
"""
"""Constructor."""
self.template = Template("""user = {{ dbuser }}
password = {{ dbpass }}
dbname = {{ dbname }}
@@ -69,7 +73,7 @@ query = {{ query|safe }}
continue
if v is MapFile:
continue
if not v.category in args.categories:
if v.category not in args.categories:
continue
self.__render_map(args, v)
+2
View File
@@ -5,6 +5,7 @@ from django.conf.urls import include
class ModoExtension(object):
"""Base extension class.
Each Modoboa extension must inherit from this class to be
@@ -37,6 +38,7 @@ class ModoExtension(object):
class ExtensionsPool(object):
"""The extensions manager"""
def __init__(self):
+3 -2
View File
@@ -37,6 +37,7 @@ except ImportError:
class User(PermissionsMixin):
"""Custom User model.
It overloads the way passwords are stored into the database. The
@@ -114,7 +115,7 @@ class User(PermissionsMixin):
load_core_settings()
scheme = parameters.get_admin("PASSWORD_SCHEME")
if type(raw_value) is unicode:
if isinstance(raw_value, unicode):
raw_value = raw_value.encode("utf-8")
return get_password_hasher(scheme.upper())().encrypt(raw_value)
@@ -146,7 +147,7 @@ class User(PermissionsMixin):
match = self.password_expr.match(self.password)
if match is None:
return False
if type(raw_value) is unicode:
if isinstance(raw_value, unicode):
raw_value = raw_value.encode("utf-8")
scheme = match.group(1)
val2 = match.group(2)
@@ -9,6 +9,7 @@ from modoboa.lib import parameters
class MD5CRYPTHasher(PasswordHasher):
"""
MD5-CRYPT password hasher.
@@ -29,6 +30,7 @@ class MD5CRYPTHasher(PasswordHasher):
class SHA256CRYPTHasher(PasswordHasher):
"""
SHA256-CRYPT password hasher.
@@ -51,6 +53,7 @@ class SHA256CRYPTHasher(PasswordHasher):
class SHA512CRYPTHasher(PasswordHasher):
"""
SHA512-CRYPT password hasher.
+6
View File
@@ -12,9 +12,11 @@ from django.utils.crypto import constant_time_compare
class PasswordHasher(object):
"""
Base class of all hashers.
"""
def __init__(self, target='local'):
self._target = target
@@ -61,6 +63,7 @@ class PasswordHasher(object):
class PLAINHasher(PasswordHasher):
"""
Plain (ie. clear) password hasher.
"""
@@ -73,6 +76,7 @@ class PLAINHasher(PasswordHasher):
class CRYPTHasher(PasswordHasher):
"""
crypt password hasher.
@@ -89,6 +93,7 @@ class CRYPTHasher(PasswordHasher):
class MD5Hasher(PasswordHasher):
"""
MD5 password hasher.
@@ -104,6 +109,7 @@ class MD5Hasher(PasswordHasher):
class SHA256Hasher(PasswordHasher):
"""
SHA256 password hasher.
+1
View File
@@ -158,6 +158,7 @@ def get_version():
class ConnectedUsers(template.Node):
def __init__(self, varname):
self.varname = varname
@@ -212,9 +212,9 @@ def dump_bodystructure(bs, depth=0):
if __name__ == "__main__":
# resp = [('855 (UID 46931 BODYSTRUCTURE ((("text" "plain" ("charset" "iso-8859-1") NIL NIL "quoted-printable" 886 32 NIL NIL NIL NIL)("text" "html" ("charset" "us-ascii") NIL NIL "quoted-printable" 1208 16 NIL NIL NIL NIL) "alternative" ("boundary" "----=_NextPart_001_0003_01CCC564.B2F64FF0") NIL NIL NIL)("application" "octet-stream" ("name" "Carte Verte_2.pdf") NIL NIL "base64" 285610 NIL ("attachment" ("filename" "Carte Verte_2.pdf")) NIL NIL) "mixed" ("boundary" "----=_NextPart_000_0002_01CCC564.B2F64FF0") NIL NIL NIL) BODY[HEADER.FIELDS (DATE FROM TO CC SUBJECT)] {153}', 'From: <Service.client10@maaf.fr>\r\nTo: <TONIO@NGYN.ORG>\r\nCc: \r\nSubject: Notre contact du 28/12/2011 - 192175092\r\nDate: Wed, 28 Dec 2011 13:29:17 +0100\r\n\r\n'), ')']
# resp = [('855 (UID 46931 BODYSTRUCTURE ((("text" "plain" ("charset" "iso-8859-1") NIL NIL "quoted-printable" 886 32 NIL NIL NIL NIL)("text" "html" ("charset" "us-ascii") NIL NIL "quoted-printable" 1208 16 NIL NIL NIL NIL) "alternative" ("boundary" "----=_NextPart_001_0003_01CCC564.B2F64FF0") NIL NIL NIL)("application" "octet-stream" ("name" "Carte Verte_2.pdf") NIL NIL "base64" 285610 NIL ("attachment" ("filename" "Carte Verte_2.pdf")) NIL NIL) "mixed" ("boundary" "----=_NextPart_000_0002_01CCC564.B2F64FF0") NIL NIL NIL) BODY[HEADER.FIELDS (DATE FROM TO CC SUBJECT)] {153}', 'From: <Service.client10@maaf.fr>\r\nTo: <TONIO@NGYN.ORG>\r\nCc: \r\nSubject: Notre contact du 28/12/2011 - 192175092\r\nDate: Wed, 28 Dec 2011 13:29:17 +0100\r\n\r\n'), ')']
# #resp = [('856 (UID 46936 BODYSTRUCTURE (("text" "plain" ("charset" "ISO-8859-1") NIL NIL "quoted-printable" 724 22 NIL NIL NIL NIL)("text" "html" ("charset" "ISO-8859-1") NIL NIL "quoted-printable" 2662 48 NIL NIL NIL NIL) "alternative" ("boundary" "----=_Part_1326887_254624357.1325083973970") NIL NIL NIL) BODY[HEADER.FIELDS (DATE FROM TO CC SUBJECT)] {258}', 'Date: Wed, 28 Dec 2011 15:52:53 +0100 (CET)\r\nFrom: =?ISO-8859-1?Q?Malakoff_M=E9d=E9ric?= <communication@communication.malakoffmederic.com>\r\nTo: Antoine Nguyen <tonio@ngyn.org>\r\nSubject: =?ISO-8859-1?Q?Votre_inscription_au_grand_Jeu_Malakoff_M=E9d=E9ric?=\r\n\r\n'), ')']
# resp = [('856 (UID 46936 BODYSTRUCTURE (("text" "plain" ("charset" "ISO-8859-1") NIL NIL "quoted-printable" 724 22 NIL NIL NIL NIL)("text" "html" ("charset" "ISO-8859-1") NIL NIL "quoted-printable" 2662 48 NIL NIL NIL NIL) "alternative" ("boundary" "----=_Part_1326887_254624357.1325083973970") NIL NIL NIL) BODY[HEADER.FIELDS (DATE FROM TO CC SUBJECT)] {258}', 'Date: Wed, 28 Dec 2011 15:52:53 +0100 (CET)\r\nFrom: =?ISO-8859-1?Q?Malakoff_M=E9d=E9ric?= <communication@communication.malakoffmederic.com>\r\nTo: Antoine Nguyen <tonio@ngyn.org>\r\nSubject: =?ISO-8859-1?Q?Votre_inscription_au_grand_Jeu_Malakoff_M=E9d=E9ric?=\r\n\r\n'), ')']
resp = [
('856 (UID 11111 BODYSTRUCTURE ((("text" "plain" ("charset" "UTF-8") NIL NIL "7bit" 0 0 NIL NIL NIL NIL) "mixed" ("boundary" "----=_Part_407172_3159001.1321948277321") NIL NIL NIL)("application" "octet-stream" ("name" "26274308.pdf") NIL NIL "base64" 14906 NIL ("attachment" ("filename" "26274308.pdf")) NIL NIL) "mixed" ("boundary" "----=_Part_407171_9686991.1321948277321") NIL NIL NIL)',
+8 -3
View File
@@ -1,15 +1,20 @@
# coding: utf-8
"""postfixadmin models."""
# This is an auto-generated Django model module.
# You'll have to do the following manually to clean this up:
# * Rearrange models' order
# * Make sure each model has one field with primary_key=True
# Feel free to rename the models, but don't rename db_table values or field names.
# Feel free to rename the models, but don't rename db_table values or
# field names.
#
# Also note: You'll have to insert the output of 'django-admin.py sqlcustom [appname]'
# into your database.
# Also note: You'll have to insert the output of 'django-admin.py
# sqlcustom [appname]' into your database.
from django.db import models
class Admin(models.Model):
username = models.CharField(max_length=255, primary_key=True)
password = models.CharField(max_length=255)