Change format strings
authorThierry Florac <tflorac@ulthar.net>
Sat, 28 Feb 2015 15:23:57 +0100
changeset 6 1a562df03e2d
parent 5 181b8ff133b7
child 7 7920b5e679ec
Change format strings
src/pyams_security/plugin/userfolder.py
--- a/src/pyams_security/plugin/userfolder.py	Sat Feb 28 15:23:28 2015 +0100
+++ b/src/pyams_security/plugin/userfolder.py	Sat Feb 28 15:23:57 2015 +0100
@@ -63,7 +63,8 @@
 
     @property
     def title(self):
-        return '{0} {1}'.format(self.firstname, self.lastname)
+        return '{firstname} {lastname}'.format(firstname=self.firstname,
+                                               lastname=self.lastname)
 
     @property
     def password(self):
@@ -116,7 +117,8 @@
 @adapter_config(context=ILocalUser, provides=IPrincipalInfo)
 def UserPrincipalInfoAdapter(user):
     """User principal info adapter"""
-    return PrincipalInfo(id="{0}:{1}".format(user.__parent__.prefix, user.login),
+    return PrincipalInfo(id="{prefix}:{login}".format(prefix=user.__parent__.prefix,
+                                                      login=user.login),
                          title=user.title)
 
 
@@ -137,7 +139,8 @@
         if principal is not None:
             password = attrs.get('password')
             if principal.check_password(password):
-                return "{0}:{1}".format(self.prefix, principal.login)
+                return "{prefix}:{login}".format(prefix=self.prefix,
+                                                 login=principal.login)
 
     def check_login(self, login):
         if not login:
@@ -152,7 +155,8 @@
         prefix, login = principal_id.split(':', 1)
         user = self.get(login)
         if user is not None:
-            return PrincipalInfo(id='{0}:{1}'.format(self.prefix, user.login),
+            return PrincipalInfo(id='{prefix}:{login}'.format(prefix=self.prefix,
+                                                              login=user.login),
                                  title=user.title)
 
     def get_all_principals(self, principal_id):
@@ -174,8 +178,10 @@
                     query in user.firstname.lower() or
                     query in user.lastname.lower() or
                     query in user.email.lower()):
-                yield PrincipalInfo(id='{0}:{1}'.format(self.prefix, user.login),
-                                    title='{0} <{1}>'.format(user.title, user.email))
+                yield PrincipalInfo(id='{prefix}:{login}'.format(prefix=self.prefix,
+                                                                 login=user.login),
+                                    title='{title} <{email}>'.format(title=user.title,
+                                                                     email=user.email))
 
     def get_search_results(self, data):
         # TODO: use inner text catalog for more efficient search?