changeset 1870:9406e02388cf

reduce usage of .keys()
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sat, 10 Mar 2007 23:16:23 +0100
parents 88326c62ae53
children 89a95d272881
files MoinMoin/PageEditor.py MoinMoin/action/LikePages.py MoinMoin/action/info.py MoinMoin/auth/php_session.py MoinMoin/formatter/text_html.py MoinMoin/macro/PageHits.py MoinMoin/macro/__init__.py MoinMoin/parser/text_rst.py MoinMoin/request/MODPYTHON.py MoinMoin/request/__init__.py MoinMoin/script/maint/mkpagepacks.py MoinMoin/script/old/xmlrpc-tools/wikirestore.py MoinMoin/support/thfcgi.py MoinMoin/util/__init__.py MoinMoin/util/thread_monitor.py MoinMoin/widget/html.py MoinMoin/wikiutil.py MoinMoin/wikixml/util.py
diffstat 18 files changed, 22 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/PageEditor.py	Sat Mar 10 22:54:25 2007 +0100
+++ b/MoinMoin/PageEditor.py	Sat Mar 10 23:16:23 2007 +0100
@@ -745,7 +745,7 @@
 
             # send email to all subscribers
             results = [_('Status of sending notification mails:')]
-            for lang in subscribers.keys():
+            for lang in subscribers:
                 emails = [u.email for u in subscribers[lang]]
                 names = [u.name for u in subscribers[lang]]
                 mailok, status = self._sendNotification(comment, emails, lang, revisions, trivial)
--- a/MoinMoin/action/LikePages.py	Sat Mar 10 22:54:25 2007 +0100
+++ b/MoinMoin/action/LikePages.py	Sat Mar 10 23:16:23 2007 +0100
@@ -102,7 +102,7 @@
 
     # Filter deleted pages or pages the user can't read from
     # matches. Order is important!
-    for name in matches.keys():
+    for name in matches:
         page = Page(request, name)
         if not (page.exists() and request.user.may.read(name)):
             del matches[name]
--- a/MoinMoin/action/info.py	Sat Mar 10 22:54:25 2007 +0100
+++ b/MoinMoin/action/info.py	Sat Mar 10 23:16:23 2007 +0100
@@ -51,7 +51,7 @@
         if subscribers:
             request.write(f.paragraph(1))
             request.write(f.text(_('The following users subscribed to this page:')))
-            for lang in subscribers.keys():
+            for lang in subscribers:
                 request.write(f.linebreak(), f.text('[%s] ' % lang))
                 for user in subscribers[lang]:
                     # do NOT disclose email addr, only WikiName
--- a/MoinMoin/auth/php_session.py	Sat Mar 10 22:54:25 2007 +0100
+++ b/MoinMoin/auth/php_session.py	Sat Mar 10 23:16:23 2007 +0100
@@ -52,7 +52,7 @@
         except Cookie.CookieError: # ignore invalid cookies
             cookie = None
         if cookie:
-            for cookiename in cookie.keys():
+            for cookiename in cookie:
                 cookievalue = urllib.unquote(cookie[cookiename].value).decode('iso-8859-1')
                 session = _PHPsessionParser.loadSession(cookievalue, path=self.s_path, prefix=self.s_prefix)
                 if session:
--- a/MoinMoin/formatter/text_html.py	Sat Mar 10 22:54:25 2007 +0100
+++ b/MoinMoin/formatter/text_html.py	Sat Mar 10 23:16:23 2007 +0100
@@ -288,7 +288,7 @@
         # Check all the HTML attributes to see if they are known and
         # allowed.  Ignore attributes if in non-HTML namespaces.
         if allowed_attrs:
-            for name in [key[1] for key in attributes.keys() if key[0] == 'html']:
+            for name in [key[1] for key in attributes if key[0] == 'html']:
                 if name in _common_attributes or name in allowed_attrs:
                     pass
                 elif name.startswith('on'):
--- a/MoinMoin/macro/PageHits.py	Sat Mar 10 22:54:25 2007 +0100
+++ b/MoinMoin/macro/PageHits.py	Sat Mar 10 23:16:23 2007 +0100
@@ -69,7 +69,7 @@
     def filterReadableHits(self, hits):
         """ Filter out hits the user many not see """
         userMayRead = self.request.user.may.read
-        for pagename in hits.keys():
+        for pagename in hits:
             page = Page(self.request, pagename)
             if page.exists() and userMayRead(pagename):
                 continue
--- a/MoinMoin/macro/__init__.py	Sat Mar 10 22:54:25 2007 +0100
+++ b/MoinMoin/macro/__init__.py	Sat Mar 10 23:16:23 2007 +0100
@@ -80,7 +80,7 @@
 
     # we need the lang macros to execute when html is generated,
     # to have correct dir and lang html attributes
-    for lang in i18n.wikiLanguages().keys():
+    for lang in i18n.wikiLanguages():
         Dependencies[lang] = []
 
 
@@ -197,8 +197,7 @@
                     map[word] = [name]
 
         # Sort ignoring case
-        all_words = map.keys()
-        tmp = [(word.upper(), word) for word in all_words]
+        tmp = [(word.upper(), word) for word in map]
         tmp.sort()
         all_words = [item[1] for item in tmp]
 
--- a/MoinMoin/parser/text_rst.py	Sat Mar 10 22:54:25 2007 +0100
+++ b/MoinMoin/parser/text_rst.py	Sat Mar 10 23:16:23 2007 +0100
@@ -87,7 +87,7 @@
 # Go through and change all docutils modules to use a dummyOpen and dummyUrllib2
 # module. Also make sure that any docutils imported modules also get the dummy
 # implementations.
-for i in sys.modules.keys():
+for i in sys.modules:
     if i.startswith('docutils') and sys.modules[i]:
         sys.modules[i].open = dummyOpen
         sys.modules[i].urllib2 = dummyUrllib2
--- a/MoinMoin/request/MODPYTHON.py	Sat Mar 10 22:54:25 2007 +0100
+++ b/MoinMoin/request/MODPYTHON.py	Sat Mar 10 23:16:23 2007 +0100
@@ -84,7 +84,7 @@
         form = util.FieldStorage(self.mpyreq)
 
         args = {}
-        for key in form.keys():
+        for key in form:
             if key is None:
                 continue
             values = form[key]
--- a/MoinMoin/request/__init__.py	Sat Mar 10 22:54:25 2007 +0100
+++ b/MoinMoin/request/__init__.py	Sat Mar 10 23:16:23 2007 +0100
@@ -96,7 +96,7 @@
 
     def dump(self):
         outlist = []
-        for timer in self.timings.keys():
+        for timer in self.timings:
             value = self.value(timer)
             outlist.append("%s = %s" % (timer, value))
         outlist.sort()
--- a/MoinMoin/script/maint/mkpagepacks.py	Sat Mar 10 22:54:25 2007 +0100
+++ b/MoinMoin/script/maint/mkpagepacks.py	Sat Mar 10 23:16:23 2007 +0100
@@ -60,7 +60,7 @@
 
         pageSets[ALL] = langPages
 
-        for name in pageSets.keys():
+        for name in pageSets:
             if name not in (u"English"):
                 pageSets[name] -= pageSets[u"English"]
                 pageSets[name] -= nodistPages
@@ -125,7 +125,7 @@
         script = [packLine(['MoinMoinPackage', '1']), ]
 
         script += [packLine(["InstallPackage", "SystemPagesSetup", name + ".zip"])
-                   for name in bundledict.keys() if name not in (NODIST, EXTRA, ALL, u"English")]
+                   for name in bundledict if name not in (NODIST, EXTRA, ALL, u"English")]
         script += [packLine(['Print', 'Installed all MoinMaster page bundles.'])]
 
         zf.writestr(MOIN_PACKAGE_FILE, u"\n".join(script).encode("utf-8"))
--- a/MoinMoin/script/old/xmlrpc-tools/wikirestore.py	Sat Mar 10 22:54:25 2007 +0100
+++ b/MoinMoin/script/old/xmlrpc-tools/wikirestore.py	Sat Mar 10 23:16:23 2007 +0100
@@ -34,8 +34,7 @@
     backup = pickle.load(backupfile)
     backupfile.close()
 
-    allpages = backup.keys()
-    for pagename in allpages:
+    for pagename in backup:
         pagedata = backup[pagename]
         dstwiki.putPage(pagename, pagedata) # TODO: add error check
         print "Put %s." % pagename
--- a/MoinMoin/support/thfcgi.py	Sat Mar 10 22:54:25 2007 +0100
+++ b/MoinMoin/support/thfcgi.py	Sat Mar 10 23:16:23 2007 +0100
@@ -220,7 +220,7 @@
 
         elif self.rec_type == FCGI_GET_VALUES or self.rec_type == FCGI_PARAMS:
             content = ""
-            for i in self.values.keys():
+            for i in self.values:
                 content = content + self.write_pair(i, self.values[i])
 
         elif self.rec_type == FCGI_END_REQUEST:
@@ -407,7 +407,7 @@
                       'FCGI_MPXS_CONNS': FCGI_MPXS_CONNS,
                      }
 
-            for name in rec.values.keys():
+            for name in rec.values:
                 if name in params:
                     # We known this value, include in reply
                     reply_rec.values[name] = params[name]
--- a/MoinMoin/util/__init__.py	Sat Mar 10 22:54:25 2007 +0100
+++ b/MoinMoin/util/__init__.py	Sat Mar 10 23:16:23 2007 +0100
@@ -89,7 +89,7 @@
     from MoinMoin import wikiutil
 
     result = '<dt><strong>Form entries</strong></dt>'
-    for k in form.keys():
+    for k in form:
         v = form.get(k, ["<empty>"])
         v = "|".join(v)
         result = result + '<dd><em>%s</em>=%s</dd>' % (k, wikiutil.escape(v))
--- a/MoinMoin/util/thread_monitor.py	Sat Mar 10 22:54:25 2007 +0100
+++ b/MoinMoin/util/thread_monitor.py	Sat Mar 10 23:16:23 2007 +0100
@@ -105,7 +105,7 @@
             return
         dumpfile = dumpfile or sys.stderr
         cur_frames = sys._current_frames()
-        for i in cur_frames.keys():
+        for i in cur_frames:
             s = StringIO()
             print >>s, "\nDumping thread (id %s):" % (i, )
             traceback.print_stack(cur_frames[i], file=s)
--- a/MoinMoin/widget/html.py	Sat Mar 10 22:54:25 2007 +0100
+++ b/MoinMoin/widget/html.py	Sat Mar 10 23:16:23 2007 +0100
@@ -59,7 +59,7 @@
     }
 
     def __init__(self, **kw):
-        for key in kw.keys():
+        for key in kw:
             key = key.lower()
             if key not in self._ATTRS:
                 raise AttributeError(
--- a/MoinMoin/wikiutil.py	Sat Mar 10 22:54:25 2007 +0100
+++ b/MoinMoin/wikiutil.py	Sat Mar 10 23:16:23 2007 +0100
@@ -1386,7 +1386,7 @@
                 parameter_list[nr] = value
 
             #Let's populate and map our dictionary to what's been found
-            for name in self.param_dict.keys():
+            for name in self.param_dict:
                 tmp = self.param_dict[name]
                 parameter_dict[name]=parameter_list[tmp]
 
@@ -1467,7 +1467,7 @@
     # check whether we have to map URLs
     if request.cfg.url_mappings:
         # check URL for the configured prefixes
-        for prefix in request.cfg.url_mappings.keys():
+        for prefix in request.cfg.url_mappings:
             if url.startswith(prefix):
                 # substitute prefix with replacement value
                 return request.cfg.url_mappings[prefix] + url[len(prefix):]
--- a/MoinMoin/wikixml/util.py	Sat Mar 10 22:54:25 2007 +0100
+++ b/MoinMoin/wikixml/util.py	Sat Mar 10 23:16:23 2007 +0100
@@ -45,7 +45,7 @@
             self.startPrefixMapping(prefix or None, uri)
 
     def endDocument(self):
-        for prefix in self.xmlns.keys():
+        for prefix in self.xmlns:
             self.endPrefixMapping(prefix or None)
         saxutils.XMLGenerator.endDocument(self)