Browse Source

Cleans up following PEP8 rules

Adrien Panay 7 years ago
parent
commit
5bfc1f46c9
1 changed files with 27 additions and 27 deletions
  1. 27 27
      tracim/tracim/model/auth.py

+ 27 - 27
tracim/tracim/model/auth.py View File

@@ -6,32 +6,34 @@ This is where the models used by the authentication stack are defined.
6 6
 
7 7
 It's perfectly fine to re-use this definition in the tracim application,
8 8
 though.
9
-
10 9
 """
10
+import os
11
+import time
11 12
 import uuid
12 13
 
13
-import os
14 14
 from datetime import datetime
15
-import time
16
-from hashlib import sha256
17
-from sqlalchemy.ext.hybrid import hybrid_property
18
-from tracim.lib.utils import lazy_ugettext as l_
19 15
 from hashlib import md5
20
-
21
-__all__ = ['User', 'Group', 'Permission']
16
+from hashlib import sha256
22 17
 
23 18
 from sqlalchemy import Column
24 19
 from sqlalchemy import ForeignKey
25 20
 from sqlalchemy import Sequence
26 21
 from sqlalchemy import Table
27
-
28
-from sqlalchemy.types import Unicode
29
-from sqlalchemy.types import Integer
30
-from sqlalchemy.types import DateTime
22
+from sqlalchemy.ext.hybrid import hybrid_property
23
+from sqlalchemy.orm import relation
24
+from sqlalchemy.orm import relationship
25
+from sqlalchemy.orm import synonym
31 26
 from sqlalchemy.types import Boolean
32
-from sqlalchemy.orm import relation, relationship, synonym
33
-from tg import request
34
-from tracim.model import DeclarativeBase, metadata, DBSession
27
+from sqlalchemy.types import DateTime
28
+from sqlalchemy.types import Integer
29
+from sqlalchemy.types import Unicode
30
+
31
+from tracim.lib.utils import lazy_ugettext as l_
32
+from tracim.model import DBSession
33
+from tracim.model import DeclarativeBase
34
+from tracim.model import metadata
35
+
36
+__all__ = ['User', 'Group', 'Permission']
35 37
 
36 38
 # This is the association table for the many-to-many relationship between
37 39
 # groups and permissions.
@@ -51,6 +53,7 @@ user_group_table = Table('user_group', metadata,
51 53
         onupdate="CASCADE", ondelete="CASCADE"), primary_key=True)
52 54
 )
53 55
 
56
+
54 57
 class Group(DeclarativeBase):
55 58
 
56 59
     TIM_NOBODY = 0
@@ -84,10 +87,8 @@ class Group(DeclarativeBase):
84 87
         return DBSession.query(cls).filter_by(group_name=group_name).first()
85 88
 
86 89
 
87
-
88 90
 class Profile(object):
89
-    """ This model is the "max" group associated to a given user
90
-    """
91
+    """This model is the "max" group associated to a given user."""
91 92
 
92 93
     _NAME = [Group.TIM_NOBODY_GROUPNAME,
93 94
              Group.TIM_USER_GROUPNAME,
@@ -106,15 +107,14 @@ class Profile(object):
106 107
         self.label = Profile._LABEL[profile_id]
107 108
 
108 109
 
109
-
110 110
 class User(DeclarativeBase):
111 111
     """
112 112
     User definition.
113 113
 
114 114
     This is the user definition used by :mod:`repoze.who`, which requires at
115 115
     least the ``email`` column.
116
-
117 116
     """
117
+
118 118
     __tablename__ = 'users'
119 119
 
120 120
     user_id = Column(Integer, Sequence('seq__users__user_id'), autoincrement=True, primary_key=True)
@@ -151,7 +151,7 @@ class User(DeclarativeBase):
151 151
     @property
152 152
     def profile(self) -> Profile:
153 153
         profile_id = 0
154
-        if len(self.groups)>0:
154
+        if len(self.groups) > 0:
155 155
             profile_id = max(group.group_id for group in self.groups)
156 156
         return Profile(profile_id)
157 157
 
@@ -223,7 +223,7 @@ class User(DeclarativeBase):
223 223
 
224 224
     webdav_left_digest_response_hash = synonym('_webdav_left_digest_response_hash',
225 225
                                                descriptor=property(_get_hash_digest,
226
-                                                                    _set_hash_digest))
226
+                                                                   _set_hash_digest))
227 227
 
228 228
     def update_webdav_digest_auth(self, cleartext_password) -> None:
229 229
         self.webdav_left_digest_response_hash \
@@ -232,7 +232,6 @@ class User(DeclarativeBase):
232 232
                 cleartext_password=cleartext_password,
233 233
             )
234 234
 
235
-
236 235
     def validate_password(self, cleartext_password):
237 236
         """
238 237
         Check the password against existing credentials.
@@ -256,11 +255,13 @@ class User(DeclarativeBase):
256 255
 
257 256
     def get_display_name(self, remove_email_part=False):
258 257
         """
258
+        Get a name to display from corresponding member or email.
259
+
259 260
         :param remove_email_part: If True and display name based on email,
260
-         remove @xxx.xxx part of email in returned value
261
+            remove @xxx.xxx part of email in returned value
261 262
         :return: display name based on user name or email.
262 263
         """
263
-        if self.display_name != None and self.display_name != '':
264
+        if self.display_name:
264 265
             return self.display_name
265 266
         else:
266 267
             if remove_email_part:
@@ -279,6 +280,7 @@ class User(DeclarativeBase):
279 280
     def ensure_auth_token(self) -> None:
280 281
         """
281 282
         Create auth_token if None, regenerate auth_token if too much old.
283
+
282 284
         auth_token validity is set in
283 285
         :return:
284 286
         """
@@ -311,7 +313,6 @@ class Permission(DeclarativeBase):
311 313
 
312 314
     __tablename__ = 'permissions'
313 315
 
314
-
315 316
     permission_id = Column(Integer, Sequence('seq__permissions__permission_id'), autoincrement=True, primary_key=True)
316 317
     permission_name = Column(Unicode(63), unique=True, nullable=False)
317 318
     description = Column(Unicode(255))
@@ -324,4 +325,3 @@ class Permission(DeclarativeBase):
324 325
 
325 326
     def __unicode__(self):
326 327
         return self.permission_name
327
-