changeset 232:31c1fbb101a3

remove string/Cookie import, rewrite filter/map imported from: moin--main--1.5--patch-235
author Thomas Waldmann <tw@waldmann-edv.de>
date Tue, 22 Nov 2005 21:43:32 +0000
parents 8c1468088e94
children 8c1210a6f9df
files MoinMoin/user.py
diffstat 1 files changed, 8 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/user.py	Tue Nov 22 21:19:41 2005 +0000
+++ b/MoinMoin/user.py	Tue Nov 22 21:43:32 2005 +0000
@@ -6,7 +6,7 @@
     @license: GNU GPL, see COPYING for details.
 """
 
-import os, string, time, Cookie, sha, codecs
+import os, time, sha, codecs
 
 try:
     import cPickle as pickle
@@ -30,7 +30,7 @@
     import re, dircache
     user_re = re.compile(r'^\d+\.\d+(\.\d+)?$')
     files = dircache.listdir(request.cfg.user_dir)
-    userlist = filter(user_re.match, files)
+    userlist = [f for f in files if user_re.match(f)]
     return userlist
 
 
@@ -437,7 +437,6 @@
             return False, False 
                 
         # First get all available pre13 charsets on this system
-        import codecs
         pre13 = ['iso-8859-1', 'iso-8859-2', 'euc-jp', 'gb2312', 'big5',]
         available = []
         for charset in pre13:
@@ -822,7 +821,7 @@
                 return
 
             # Append new page, limiting the length
-            self._trail = filter(lambda p, pn=pagename: p != pn, self._trail)
+            self._trail = [p for p in self._trail if p != pagename]
             self._trail = self._trail[-(self._cfg.trail_size-1):]
             self._trail.append(pagename)
             self.saveTrail()
@@ -862,12 +861,12 @@
                 and not self._trail \
                 and os.path.exists(self.__filename() + ".trail"):
             try:
-                self._trail = codecs.open(self.__filename() + ".trail", 'r', config.charset).readlines()
+                trail = codecs.open(self.__filename() + ".trail", 'r', config.charset).readlines()
             except (OSError, ValueError):
-                self._trail = []
-            else:
-                self._trail = filter(None, map(string.strip, self._trail))
-                self._trail = self._trail[-self._cfg.trail_size:]
+                trail = []
+            trail = [t.strip() for t in trail]
+            trail = [t for t in trail if t]
+            self._trail = trail[-self._cfg.trail_size:]
 
         return self._trail