changeset 2595:5e7b45489430

moved python2.3/2.4 compatibility code to MoinMoin.support.python_compatibility (thanks to Heinrich Wendel)
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Fri, 03 Aug 2007 13:30:42 +0200
parents dae34d586476
children 86295432620c
files MoinMoin/PageEditor.py MoinMoin/action/SyncPages.py MoinMoin/config/_tests/test_multiconfig.py MoinMoin/config/multiconfig.py MoinMoin/conftest.py MoinMoin/events/emailnotify.py MoinMoin/events/jabbernotify.py MoinMoin/formatter/text_html.py MoinMoin/macro/AdvancedSearch.py MoinMoin/request/__init__.py MoinMoin/support/__init__.py MoinMoin/util/thread_monitor.py
diffstat 12 files changed, 12 insertions(+), 57 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/PageEditor.py	Fri Aug 03 11:44:46 2007 +0200
+++ b/MoinMoin/PageEditor.py	Fri Aug 03 13:30:42 2007 +0200
@@ -18,16 +18,13 @@
 
 import os, time, codecs, errno
 
-try:
-    set
-except:
-    from sets import Set as set
 
 from MoinMoin import caching, config, user, wikiutil, error
 from MoinMoin.Page import Page
 from MoinMoin.widget import html
 from MoinMoin.widget.dialog import Status
 from MoinMoin.logfile import editlog, eventlog
+from MoinMoin.support.python_compatibility import set
 from MoinMoin.util import filesys, timefuncs, web
 from MoinMoin.mail import sendmail
 from MoinMoin.events import PageDeletedEvent, PageRenamedEvent, PageCopiedEvent
--- a/MoinMoin/action/SyncPages.py	Fri Aug 03 11:44:46 2007 +0200
+++ b/MoinMoin/action/SyncPages.py	Fri Aug 03 13:30:42 2007 +0200
@@ -12,12 +12,6 @@
 import traceback
 import StringIO # not relevant for speed, so we do not need cStringIO
 
-# Compatiblity to Python 2.3
-try:
-    set
-except NameError:
-    from sets import Set as set
-
 
 from MoinMoin import wikiutil
 from MoinMoin.packages import unpackLine, packLine
@@ -26,6 +20,7 @@
 from MoinMoin.wikidicts import Dict
 from MoinMoin.wikisync import TagStore, UnsupportedWikiException, SyncPage, NotAllowedException
 from MoinMoin.wikisync import MoinLocalWiki, MoinRemoteWiki, UP, DOWN, BOTH, MIMETYPE_MOIN
+from MoinMoin.support.python_compatibility import set
 from MoinMoin.util.bdiff import decompress, patch, compress, textdiff
 from MoinMoin.util import diff3, rpc_aggregator
 
--- a/MoinMoin/config/_tests/test_multiconfig.py	Fri Aug 03 11:44:46 2007 +0200
+++ b/MoinMoin/config/_tests/test_multiconfig.py	Fri Aug 03 13:30:42 2007 +0200
@@ -6,12 +6,8 @@
     @license: GNU GPL, see COPYING for details.
 """
 
-try:
-    set
-except:
-    from sets import Set as set
-
 import py
+from MoinMoin.support.python_compatibility import set
 
 
 class TestPasswordChecker:
--- a/MoinMoin/config/multiconfig.py	Fri Aug 03 11:44:46 2007 +0200
+++ b/MoinMoin/config/multiconfig.py	Fri Aug 03 13:30:42 2007 +0200
@@ -21,6 +21,7 @@
 from MoinMoin import session
 from MoinMoin.packages import packLine
 from MoinMoin.security import AccessControlList
+from MoinMoin.support.python_compatibility import set
 
 _url_re_cache = None
 _farmconfig_mtime = None
@@ -444,10 +445,6 @@
             @return: None if there is no problem with the password,
                      some string with an error msg, if the password is problematic.
         """
-        try:
-            set
-        except:
-            from sets import Set as set
 
         try:
             # in any case, do a very simple built-in check to avoid the worst passwords
--- a/MoinMoin/conftest.py	Fri Aug 03 11:44:46 2007 +0200
+++ b/MoinMoin/conftest.py	Fri Aug 03 13:30:42 2007 +0200
@@ -36,6 +36,7 @@
 
 sys.path.insert(0, str(moindir.join("tests")))
 
+from MoinMoin.support.python_compatibility import set
 
 coverage_modules = set()
 
--- a/MoinMoin/events/emailnotify.py	Fri Aug 03 11:44:46 2007 +0200
+++ b/MoinMoin/events/emailnotify.py	Fri Aug 03 13:30:42 2007 +0200
@@ -9,14 +9,10 @@
     @license: GNU GPL, see COPYING for details.
 """
 
-try:
-    set
-except:
-    from sets import Set as set
-
 from MoinMoin import user
 from MoinMoin.Page import Page
 from MoinMoin.mail import sendmail
+from MoinMoin.support.python_compatibility import set
 from MoinMoin.user import User, getUserList
 import MoinMoin.events as ev
 import MoinMoin.events.notification as notification
--- a/MoinMoin/events/jabbernotify.py	Fri Aug 03 11:44:46 2007 +0200
+++ b/MoinMoin/events/jabbernotify.py	Fri Aug 03 13:30:42 2007 +0200
@@ -10,14 +10,10 @@
 
 import xmlrpclib
 
-try:
-    set
-except:
-    from sets import Set as set
-
 from MoinMoin import error
 from MoinMoin.Page import Page
 from MoinMoin.user import User, getUserList
+from MoinMoin.support.python_compatibility import set
 import MoinMoin.events.notification as notification
 import MoinMoin.events as ev
 
--- a/MoinMoin/formatter/text_html.py	Fri Aug 03 11:44:46 2007 +0200
+++ b/MoinMoin/formatter/text_html.py	Fri Aug 03 13:30:42 2007 +0200
@@ -7,15 +7,11 @@
 """
 import os.path, re
 
-try:
-    set
-except:
-    from sets import Set as set
-
 from MoinMoin.formatter import FormatterBase
 from MoinMoin import wikiutil, i18n
 from MoinMoin.Page import Page
 from MoinMoin.action import AttachFile
+from MoinMoin.support.python_compatibility import set
 
 # insert IDs into output wherever they occur
 # warning: breaks toggle line numbers javascript
--- a/MoinMoin/macro/AdvancedSearch.py	Fri Aug 03 11:44:46 2007 +0200
+++ b/MoinMoin/macro/AdvancedSearch.py	Fri Aug 03 13:30:42 2007 +0200
@@ -9,9 +9,9 @@
 """
 
 from MoinMoin.i18n import languages
-from MoinMoin.support import sorted
 from MoinMoin.widget import html
 from MoinMoin.util.web import makeSelection
+from MoinMoin.support.python_compatibility import sorted
 
 import mimetypes
 
--- a/MoinMoin/request/__init__.py	Fri Aug 03 11:44:46 2007 +0200
+++ b/MoinMoin/request/__init__.py	Fri Aug 03 13:30:42 2007 +0200
@@ -11,13 +11,9 @@
 import logging
 import Cookie
 
-try:
-    set
-except:
-    from sets import Set as set
-
 from MoinMoin import config, wikiutil, user, caching, error
 from MoinMoin.config import multiconfig
+from MoinMoin.support.python_compatibility import set
 from MoinMoin.util import IsWin9x
 from MoinMoin import auth
 from urllib import quote, quote_plus
--- a/MoinMoin/support/__init__.py	Fri Aug 03 11:44:46 2007 +0200
+++ b/MoinMoin/support/__init__.py	Fri Aug 03 13:30:42 2007 +0200
@@ -10,16 +10,3 @@
     @copyright: 2001-2004 Juergen Hermann <jh@web.de>
     @license: GNU GPL, see COPYING for details.
 """
-
-try:
-    sorted = sorted
-except NameError:
-    def sorted(l, *args, **kw):
-        l = l[:]
-        # py2.3 is a bit different
-        if 'cmp' in kw:
-            args = (kw['cmp'], )
-
-        l.sort(*args)
-        return l
-
--- a/MoinMoin/util/thread_monitor.py	Fri Aug 03 11:44:46 2007 +0200
+++ b/MoinMoin/util/thread_monitor.py	Fri Aug 03 13:30:42 2007 +0200
@@ -23,10 +23,8 @@
 from time import sleep
 from StringIO import StringIO
 
-try:
-    set
-except:
-    from sets import Set as set
+from MoinMoin.support.python_compatibility import set
+
 
 class AbstractMonitor(object):
     def activate_hook(self):