changeset 136:13bce99cba0b

use sorted(), use while True
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sun, 20 Mar 2011 02:41:47 +0100
parents 75312c9b94e3
children 989ada5c5cbb bf0586f3b72c
files MoinMoin/apps/frontend/views.py MoinMoin/apps/misc/views.py MoinMoin/conftest.py MoinMoin/converter/include.py MoinMoin/error.py MoinMoin/storage/_tests/test_backends.py MoinMoin/storage/backends/fs.py MoinMoin/storage/backends/fs19_logfile.py MoinMoin/storage/backends/fs2.py MoinMoin/user.py MoinMoin/util/__init__.py MoinMoin/util/diff3.py MoinMoin/util/mime.py MoinMoin/util/pysupport.py MoinMoin/util/thread_monitor.py
diffstat 15 files changed, 16 insertions(+), 28 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/apps/frontend/views.py	Sun Mar 20 02:31:24 2011 +0100
+++ b/MoinMoin/apps/frontend/views.py	Sun Mar 20 02:41:47 2011 +0100
@@ -1373,8 +1373,7 @@
     list similar item names
     """
     start, end, matches = findMatches(item_name)
-    keys = matches.keys()
-    keys.sort()
+    keys = sorted(matches.keys())
     # TODO later we could add titles for the misc ranks:
     # 8 item_name
     # 4 "%s/..." % item_name
--- a/MoinMoin/apps/misc/views.py	Sun Mar 20 02:31:24 2011 +0100
+++ b/MoinMoin/apps/misc/views.py	Sun Mar 20 02:41:47 2011 +0100
@@ -71,8 +71,7 @@
     See: http://usemod.com/cgi-bin/mb.pl?SisterSitesImplementationGuide
     """
     # XXX we currently also get user items, fix this
-    item_names = [item.name for item in flaskg.storage.iteritems()]
-    item_names.sort()
+    item_names = sorted([item.name for item in flaskg.storage.iteritems()])
     content = render_template('misc/urls_names.txt', item_names=item_names)
     return Response(content, mimetype='text/plain')
 
--- a/MoinMoin/conftest.py	Sun Mar 20 02:31:24 2011 +0100
+++ b/MoinMoin/conftest.py	Sun Mar 20 02:41:47 2011 +0100
@@ -48,8 +48,7 @@
 
     def report_coverage():
         coverage.stop()
-        module_list = [sys.modules[mod] for mod in coverage_modules]
-        module_list.sort()
+        module_list = sorted([sys.modules[mod] for mod in coverage_modules])
         coverage.report(module_list)
 
     def callback(option, opt_str, value, parser):
--- a/MoinMoin/converter/include.py	Sun Mar 20 02:31:24 2011 +0100
+++ b/MoinMoin/converter/include.py	Sun Mar 20 02:41:47 2011 +0100
@@ -199,8 +199,7 @@
                     from MoinMoin.storage.terms import NameFn
                     inc_match = re.compile(xp_include_pages)
                     root_item = Item(name=u'')
-                    pagelist = [item.name for item in root_item.list_items(NameFn(inc_match))]
-                    pagelist.sort()
+                    pagelist = sorted([item.name for item in root_item.list_items(NameFn(inc_match))])
                     if xp_include_sort == 'descending':
                         pagelist.reverse()
                     if xp_include_skipitems is not None:
--- a/MoinMoin/error.py	Sun Mar 20 02:31:24 2011 +0100
+++ b/MoinMoin/error.py	Sun Mar 20 02:41:47 2011 +0100
@@ -87,7 +87,7 @@
     def exceptions(self):
         """ Return a list of all inner exceptions """
         all = [self.innerException]
-        while 1:
+        while True:
             lastException = all[-1][1]
             try:
                 all.append(lastException.innerException)
--- a/MoinMoin/storage/_tests/test_backends.py	Sun Mar 20 02:31:24 2011 +0100
+++ b/MoinMoin/storage/_tests/test_backends.py	Sun Mar 20 02:41:47 2011 +0100
@@ -203,8 +203,7 @@
             self.create_rev_item_helper(u"item_" + str(num).zfill(2))
         for num in range(10):
             self.create_meta_item_helper(u"item_" + str(num).zfill(2))
-        itemlist = [item.name for item in self.backend.iteritems()]
-        itemlist.sort()
+        itemlist = sorted([item.name for item in self.backend.iteritems()])
         for num, itemname in enumerate(itemlist):
             assert itemname == u"item_" + str(num).zfill(2)
         assert len(itemlist) == 20
--- a/MoinMoin/storage/backends/fs.py	Sun Mar 20 02:31:24 2011 +0100
+++ b/MoinMoin/storage/backends/fs.py	Sun Mar 20 02:41:47 2011 +0100
@@ -159,8 +159,7 @@
             return []
         p = os.path.join(self._path, item._fs_item_id)
         l = os.listdir(p)
-        ret = [int(i[4:]) for i in l if i.startswith('rev.')]
-        ret.sort()
+        ret = sorted([int(i[4:]) for i in l if i.startswith('rev.')])
         return ret
 
     def _create_revision(self, item, revno):
--- a/MoinMoin/storage/backends/fs19_logfile.py	Sun Mar 20 02:31:24 2011 +0100
+++ b/MoinMoin/storage/backends/fs19_logfile.py	Sun Mar 20 02:41:47 2011 +0100
@@ -112,7 +112,7 @@
         :rtype: iterator
         """
         self.to_end()
-        while 1:
+        while True:
             try:
                 logging.log(self.loglevel, "LogFile.reverse %s" % self.__filename)
                 result = self.previous()
--- a/MoinMoin/storage/backends/fs2.py	Sun Mar 20 02:31:24 2011 +0100
+++ b/MoinMoin/storage/backends/fs2.py	Sun Mar 20 02:41:47 2011 +0100
@@ -204,8 +204,7 @@
         p = self._make_path('meta', item._fs_item_id)
         l = os.listdir(p)
         suffix = '.rev'
-        ret = [int(i[:-len(suffix)]) for i in l if i.endswith(suffix)]
-        ret.sort()
+        ret = sorted([int(i[:-len(suffix)]) for i in l if i.endswith(suffix)])
         return ret
 
     def _create_revision(self, item, revno):
--- a/MoinMoin/user.py	Sun Mar 20 02:31:24 2011 +0100
+++ b/MoinMoin/user.py	Sun Mar 20 02:41:47 2011 +0100
@@ -493,8 +493,7 @@
 
         self.last_saved = int(time.time())
 
-        attrs = self.persistent_items()
-        attrs.sort()
+        attrs = sorted(self.persistent_items())
         for key, value in attrs:
             if isinstance(value, list):
                 value = tuple(value)
--- a/MoinMoin/util/__init__.py	Sun Mar 20 02:31:24 2011 +0100
+++ b/MoinMoin/util/__init__.py	Sun Mar 20 02:41:47 2011 +0100
@@ -65,8 +65,7 @@
     """ Convert a list of integers to a range string in the form
         '1,2-5,7'.
     """
-    numbers = numbers[:]
-    numbers.sort()
+    numbers = sorted(numbers[:])
     numbers.append(999999)
     pattern = ','
     for i in range(len(numbers)-1):
--- a/MoinMoin/util/diff3.py	Sun Mar 20 02:31:24 2011 +0100
+++ b/MoinMoin/util/diff3.py	Sun Mar 20 02:41:47 2011 +0100
@@ -125,7 +125,7 @@
     """find next matching pattern unchanged in both other and new
        return the position in all three lists
     """
-    while 1:
+    while True:
         difference = new_match[0] - other_match[0]
         # new changed more lines
         if difference > 0:
--- a/MoinMoin/util/mime.py	Sun Mar 20 02:31:24 2011 +0100
+++ b/MoinMoin/util/mime.py	Sun Mar 20 02:41:47 2011 +0100
@@ -74,8 +74,7 @@
     def __unicode__(self):
         ret = [u'%s/%s' % (self.type or '*', self.subtype or '*')]
 
-        parameters = self.parameters.items()
-        parameters.sort()
+        parameters = sorted(self.parameters.items())
         for key, value in parameters:
             if self.__token_check(value):
                 ret.append(u'%s=%s' % (key, value))
--- a/MoinMoin/util/pysupport.py	Sun Mar 20 02:31:24 2011 +0100
+++ b/MoinMoin/util/pysupport.py	Sun Mar 20 02:41:47 2011 +0100
@@ -30,9 +30,8 @@
     pyre = re.compile(r"^([^_].*)\.py$")
     dirlist = os.listdir(packagedir)
     matches = [pyre.match(fn) for fn in dirlist]
-    modules = [match.group(1) for match in matches if match]
+    modules = sorted([match.group(1) for match in matches if match])
 
-    modules.sort()
     return modules
 
 
@@ -59,9 +58,8 @@
         dirlist = os.listdir(packagedir)
 
     matches = [pyre.match(fn) for fn in dirlist]
-    modules = [match.group(1) for match in matches if match]
+    modules = sorted([match.group(1) for match in matches if match])
 
-    modules.sort()
     return modules
 
 
--- a/MoinMoin/util/thread_monitor.py	Sun Mar 20 02:31:24 2011 +0100
+++ b/MoinMoin/util/thread_monitor.py	Sun Mar 20 02:41:47 2011 +0100
@@ -53,7 +53,7 @@
     activate_hook()
 
     def background_dumper(seconds):
-        while 1:
+        while True:
             sleep(seconds)
             trigger_dump()