changeset 1793:2a4caa295346

Eclipse PyDev Check: fixed lots of its errors and warnings
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Fri, 23 Feb 2007 13:06:42 +0100
parents c907c2942372
children c3288587c552
files MoinMoin/PageGraphicalEditor.py MoinMoin/_tests/broken/test_converter_text_html_text_moin_wiki.py MoinMoin/action/AttachFile.py MoinMoin/action/Despam.py MoinMoin/action/SyncPages.py MoinMoin/action/info.py MoinMoin/caching.py MoinMoin/filter/EXIF.py MoinMoin/formatter/text_docbook.py MoinMoin/i18n/__init__.py MoinMoin/i18n/tools/mail_i18n-maintainers.py MoinMoin/macro/Include.py MoinMoin/macro/Login.py MoinMoin/macro/Navigation.py MoinMoin/macro/PageHits.py MoinMoin/macro/TableOfContents.py MoinMoin/packages.py MoinMoin/script/account/check.py MoinMoin/script/export/dump.py MoinMoin/script/old/xmlrpc-tools/wikibackup.py MoinMoin/script/old/xmlrpc-tools/wikirestore.py MoinMoin/search/Xapian.py MoinMoin/search/builtin.py MoinMoin/security/autoadmin.py MoinMoin/server/STANDALONE.py MoinMoin/util/__init__.py MoinMoin/widget/html.py MoinMoin/wikisync.py MoinMoin/xmlrpc/__init__.py
diffstat 29 files changed, 48 insertions(+), 74 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/PageGraphicalEditor.py	Fri Feb 23 09:38:23 2007 +0100
+++ b/MoinMoin/PageGraphicalEditor.py	Fri Feb 23 13:06:42 2007 +0100
@@ -8,7 +8,7 @@
 import re
 
 from MoinMoin import PageEditor
-from MoinMoin import util, wikiutil
+from MoinMoin import wikiutil
 from MoinMoin.Page import Page
 from MoinMoin.widget import html
 from MoinMoin.widget.dialog import Status
--- a/MoinMoin/_tests/broken/test_converter_text_html_text_moin_wiki.py	Fri Feb 23 09:38:23 2007 +0100
+++ b/MoinMoin/_tests/broken/test_converter_text_html_text_moin_wiki.py	Fri Feb 23 13:06:42 2007 +0100
@@ -11,7 +11,7 @@
 
 from cStringIO import StringIO
 from MoinMoin.converter import text_html_text_moin_wiki as converter
-from MoinMoin.parser.wiki import Parser
+from MoinMoin.parser.text_moin_wiki import Parser
 from MoinMoin.formatter.text_gedit import Formatter
 from MoinMoin.request import Clock
 
--- a/MoinMoin/action/AttachFile.py	Fri Feb 23 09:38:23 2007 +0100
+++ b/MoinMoin/action/AttachFile.py	Fri Feb 23 13:06:42 2007 +0100
@@ -673,7 +673,7 @@
         _addLogEntry(request, 'ATTDRW', pagename, basename + ext)
         filecontent = filecontent.replace("\r", "")
 
-    savepath = os.path.join(getAttachDir(request, pagename), basename + ext)
+    savepath = os.path.join(attach_dir, basename + ext)
     if ext == '.map' and not filecontent.strip():
         # delete map file if it is empty
         os.unlink(savepath)
--- a/MoinMoin/action/Despam.py	Fri Feb 23 09:38:23 2007 +0100
+++ b/MoinMoin/action/Despam.py	Fri Feb 23 13:06:42 2007 +0100
@@ -64,7 +64,6 @@
 
     timestamp = int(timestamp * 1000000)
     log = editlog.EditLog(request)
-    lines = []
     pages = {}
     #  mimic macro object for use of RecentChanges subfunctions
     macro = tmp()
--- a/MoinMoin/action/SyncPages.py	Fri Feb 23 09:38:23 2007 +0100
+++ b/MoinMoin/action/SyncPages.py	Fri Feb 23 13:06:42 2007 +0100
@@ -23,7 +23,7 @@
 from MoinMoin.packages import unpackLine, packLine
 from MoinMoin.PageEditor import PageEditor, conflict_markers
 from MoinMoin.Page import Page
-from MoinMoin.wikidicts import Dict, Group
+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.util.bdiff import decompress, patch, compress, textdiff
--- a/MoinMoin/action/info.py	Fri Feb 23 09:38:23 2007 +0100
+++ b/MoinMoin/action/info.py	Fri Feb 23 13:06:42 2007 +0100
@@ -91,10 +91,6 @@
             ]
 
         # generate history list
-        revisions = page.getRevList()
-        versions = len(revisions)
-
-        may_revert = request.user.may.revert(pagename)
 
         def render_action(text, query, **kw):
             kw.update(dict(rel='nofollow'))
--- a/MoinMoin/caching.py	Fri Feb 23 09:38:23 2007 +0100
+++ b/MoinMoin/caching.py	Fri Feb 23 13:06:42 2007 +0100
@@ -9,17 +9,7 @@
 import os
 import tempfile
 
-# cPickle can encode normal and Unicode strings
-# see http://docs.python.org/lib/node66.html
-try:
-    import cPickle as pickle
-except ImportError:
-    import pickle
-
-# Set pickle protocol, see http://docs.python.org/lib/node64.html
-PICKLE_PROTOCOL = pickle.HIGHEST_PROTOCOL
-
-from MoinMoin.util import filesys, lock
+from MoinMoin.util import filesys, lock, pickle, PICKLE_PROTOCOL
 
 
 class CacheError(Exception):
--- a/MoinMoin/filter/EXIF.py	Fri Feb 23 09:38:23 2007 +0100
+++ b/MoinMoin/filter/EXIF.py	Fri Feb 23 13:06:42 2007 +0100
@@ -798,7 +798,7 @@
     # convert offset to string
     def n2s(self, offset, length):
         s = ''
-        for i in range(length):
+        for dummy in range(length):
             if self.endian == 'I':
                 s = s + chr(offset & 0xFF)
             else:
@@ -871,14 +871,14 @@
             else:
                 values = []
                 signed = (field_type in [6, 8, 9, 10])
-                for j in range(count):
+                for dummy in range(count):
                     if field_type in (5, 10):
                         # a ratio
-                        value_j = Ratio(self.s2n(offset, 4, signed),
+                        value = Ratio(self.s2n(offset, 4, signed),
                                       self.s2n(offset+4, 4, signed))
                     else:
-                        value_j = self.s2n(offset, typelen, signed)
-                    values.append(value_j)
+                        value = self.s2n(offset, typelen, signed)
+                    values.append(value)
                     offset = offset+typelen
             # now "values" is either a string or an array
             if count == 1 and field_type != 2:
--- a/MoinMoin/formatter/text_docbook.py	Fri Feb 23 09:38:23 2007 +0100
+++ b/MoinMoin/formatter/text_docbook.py	Fri Feb 23 13:06:42 2007 +0100
@@ -157,7 +157,7 @@
             if depth <= self.curdepth:
                 # number of levels we want to go higher
                 numberOfLevels = self.curdepth-depth + 1
-                for i in range(numberOfLevels):
+                for dummy in range(numberOfLevels):
                     #find first non section node
                     while (self.cur.nodeName != "section" and self.cur.nodeName != "article"):
                         self.cur = self.cur.parentNode
--- a/MoinMoin/i18n/__init__.py	Fri Feb 23 09:38:23 2007 +0100
+++ b/MoinMoin/i18n/__init__.py	Fri Feb 23 13:06:42 2007 +0100
@@ -140,7 +140,6 @@
         from MoinMoin.formatter.text_html import Formatter
         import StringIO
 
-        origtext = text
         out = StringIO.StringIO()
         request.redirect(out)
         parser = WikiParser(text, request, line_anchors=False)
--- a/MoinMoin/i18n/tools/mail_i18n-maintainers.py	Fri Feb 23 09:38:23 2007 +0100
+++ b/MoinMoin/i18n/tools/mail_i18n-maintainers.py	Fri Feb 23 13:06:42 2007 +0100
@@ -15,7 +15,7 @@
 mail_login = None
 charset = 'iso-8859-1'
 
-from meta import languages
+from MoinMoin.i18n.meta import languages
 
 def sendmail(mfrom, mto, subject, text):
     """
--- a/MoinMoin/macro/Include.py	Fri Feb 23 09:38:23 2007 +0100
+++ b/MoinMoin/macro/Include.py	Fri Feb 23 13:06:42 2007 +0100
@@ -43,8 +43,8 @@
     for title, _ in title_re.findall(body):
         h = title.strip()
         level = 1
-        while h[level:level+1] == '=': level = level+1
-        depth = min(5, level)
+        while h[level:level+1] == '=':
+            level += 1
         title_text = h[level:-level].strip()
         titles.append((title_text, level))
     return titles
@@ -140,7 +140,6 @@
                 result.append(_sysmsg % ('warning', 'Include: ' + _('Nothing found for "%s"!')) % to_re)
 
         if titlesonly:
-            newbody = []
             levelstack = []
             for title, level in extract_titles(body[from_pos:to_pos], title_re):
                 if levelstack:
--- a/MoinMoin/macro/Login.py	Fri Feb 23 09:38:23 2007 +0100
+++ b/MoinMoin/macro/Login.py	Fri Feb 23 13:06:42 2007 +0100
@@ -22,7 +22,6 @@
     """ Show the login form (but only when not logged in) """
     request = macro.request
     _ = request.getText
-    formatter = macro.formatter
     if not args:
         if request.user.valid:
             data = u''
--- a/MoinMoin/macro/Navigation.py	Fri Feb 23 09:38:23 2007 +0100
+++ b/MoinMoin/macro/Navigation.py	Fri Feb 23 13:06:42 2007 +0100
@@ -36,7 +36,7 @@
 def _getLinks(request, pagename, filter_regex=None):
     """ Return pagename for up, first, prev, next, last; each can be None.
     """
-    pos, size, first, prev, next, last = 0, 0, None, None, None, None
+    pos, first, prev, next, last = 0, None, None, None, None
 
     all_pages = _getPages(request, filter_regex)
     size = len(all_pages)
--- a/MoinMoin/macro/PageHits.py	Fri Feb 23 09:38:23 2007 +0100
+++ b/MoinMoin/macro/PageHits.py	Fri Feb 23 13:06:42 2007 +0100
@@ -17,7 +17,7 @@
     def __init__(self, macro, args):
         self.macro = macro
         self.request = macro.request
-        self.cache = cache = caching.CacheEntry(self.request, 'charts', 'pagehits', scope='wiki', use_pickle=True)
+        self.cache = caching.CacheEntry(self.request, 'charts', 'pagehits', scope='wiki', use_pickle=True)
 
     def execute(self):
         """ Execute the macro and return output """
--- a/MoinMoin/macro/TableOfContents.py	Fri Feb 23 09:38:23 2007 +0100
+++ b/MoinMoin/macro/TableOfContents.py	Fri Feb 23 13:06:42 2007 +0100
@@ -79,7 +79,7 @@
         self.process_lines(self.pre_re.sub('', self.macro.parser.raw).split('\n'),
                            self.macro.formatter.page.page_name)
         # Close pending lists
-        for i in range(self.baseindent, self.indent):
+        for dummy in range(self.baseindent, self.indent):
             self.result.append(self.macro.formatter.listitem(0))
             self.result.append(self.macro.formatter.number_list(0))
         self.result.append(self.macro.formatter.div(0))
@@ -138,12 +138,12 @@
             self.indent = self.baseindent
 
         # Close lists
-        for i in range(0, self.indent-newindent):
+        for dummy in range(0, self.indent-newindent):
             self.result.append(self.macro.formatter.listitem(0))
             self.result.append(self.macro.formatter.number_list(0))
 
         # Open Lists
-        for i in range(0, newindent-self.indent):
+        for dummy in range(0, newindent-self.indent):
             self.result.append(self.macro.formatter.number_list(1))
             self.result.append(self.macro.formatter.listitem(1))
 
--- a/MoinMoin/packages.py	Fri Feb 23 09:38:23 2007 +0100
+++ b/MoinMoin/packages.py	Fri Feb 23 13:06:42 2007 +0100
@@ -41,7 +41,6 @@
 
 def event_logfile(self, pagename, pagefile):
     # add event log entry
-    filename = self.request.rootpage.getPagePath('event-log', isfile=1)
     eventtype = 'SAVENEW'
     mtime_usecs = wikiutil.timestamp2version(os.path.getmtime(pagefile))
     elog = eventlog.EventLog(self.request)
@@ -116,6 +115,7 @@
         #Satisfy pylint
         self.msg = getattr(self, "msg", "")
         self.request = getattr(self, "request", None)
+
     def do_addattachment(self, zipname, filename, pagename, author=u"Scripting Subsystem", comment=u""):
         """
         Installs an attachment
--- a/MoinMoin/script/account/check.py	Fri Feb 23 09:38:23 2007 +0100
+++ b/MoinMoin/script/account/check.py	Fri Feb 23 13:06:42 2007 +0100
@@ -171,7 +171,7 @@
         sortlist.sort()
         #print sortlist
         # disable all, but the last/latest one
-        for t, uid in sortlist[:-1]:
+        for dummy, uid in sortlist[:-1]:
             self.disableUser(uid)
         # show what will be kept
         uid = sortlist[-1][1]
--- a/MoinMoin/script/export/dump.py	Fri Feb 23 09:38:23 2007 +0100
+++ b/MoinMoin/script/export/dump.py	Fri Feb 23 13:06:42 2007 +0100
@@ -126,7 +126,7 @@
 
         wikiutil.quoteWikinameURL = lambda pagename, qfn=wikiutil.quoteWikinameFS: (qfn(pagename) + HTML_SUFFIX)
 
-        AttachFile.getAttachUrl = lambda pagename, filename, request, addts=0, escaped=0: (_attachment(request, pagename, filename, outputdir))
+        AttachFile.getAttachUrl = lambda pagename, filename, request: (_attachment(request, pagename, filename, outputdir))
 
         errfile = os.path.join(outputdir, 'error.log')
         errlog = open(errfile, 'w')
--- a/MoinMoin/script/old/xmlrpc-tools/wikibackup.py	Fri Feb 23 09:38:23 2007 +0100
+++ b/MoinMoin/script/old/xmlrpc-tools/wikibackup.py	Fri Feb 23 13:06:42 2007 +0100
@@ -21,6 +21,7 @@
 def run():
     import xmlrpclib
     from MoinMoin.support.BasicAuthTransport import BasicAuthTransport
+    from MoinMoin.util import pickle, PICKLE_PROTOCOL
 
     #user = "username"
     #password = "xxxxxxxx"
@@ -28,14 +29,6 @@
     #srcwiki = xmlrpclib.ServerProxy("http://devel.linuxwiki.org/moin--cvs/__xmlrpc/?action=xmlrpc2", transport=srctrans)
     srcwiki = xmlrpclib.ServerProxy("http://devel.linuxwiki.org/moin--cvs/?action=xmlrpc2")
 
-    try:
-        import cPickle as pickle
-    except ImportError:
-        import pickle
-
-    # Set pickle protocol, see http://docs.python.org/lib/node64.html
-    PICKLE_PROTOCOL = pickle.HIGHEST_PROTOCOL
-
     backup={}
     allpages = srcwiki.getAllPages()
     for pagename in allpages:
--- a/MoinMoin/script/old/xmlrpc-tools/wikirestore.py	Fri Feb 23 09:38:23 2007 +0100
+++ b/MoinMoin/script/old/xmlrpc-tools/wikirestore.py	Fri Feb 23 13:06:42 2007 +0100
@@ -22,6 +22,7 @@
 def run():
     import xmlrpclib
     from MoinMoin.support.BasicAuthTransport import BasicAuthTransport
+    from MoinMoin.util import pickle
 
     user = "ThomasWaldmann"
     password = "xxxxxxxxxxxx"
@@ -29,11 +30,6 @@
     dstwiki = xmlrpclib.ServerProxy("http://devel.linuxwiki.org/moin--cvs/__xmlrpc/?action=xmlrpc2", transport=dsttrans)
     #dstwiki = xmlrpclib.ServerProxy("http://devel.linuxwiki.org/moin--cvs/?action=xmlrpc2")
 
-    try:
-        import cPickle as pickle
-    except ImportError:
-        import pickle
-
     backupfile = open("wikibackup.pickle","r")
     backup = pickle.load(backupfile)
     backupfile.close()
@@ -46,4 +42,3 @@
 
 if __name__ == "__main__":
     run()
-
--- a/MoinMoin/search/Xapian.py	Fri Feb 23 09:38:23 2007 +0100
+++ b/MoinMoin/search/Xapian.py	Fri Feb 23 13:06:42 2007 +0100
@@ -11,7 +11,7 @@
 import os, re
 
 import xapian
-from xapian import Query
+
 from MoinMoin.support.xapwrap import document as xapdoc
 from MoinMoin.support.xapwrap import index as xapidx
 from MoinMoin.parser.text_moin_wiki import Parser as WikiParser
--- a/MoinMoin/search/builtin.py	Fri Feb 23 09:38:23 2007 +0100
+++ b/MoinMoin/search/builtin.py	Fri Feb 23 13:06:42 2007 +0100
@@ -167,7 +167,6 @@
         @param request: current request
         """
         self.request = request
-        cache_dir = request.cfg.cache_dir
         main_dir = self._main_dir()
         self.dir = os.path.join(main_dir, 'index')
         if not os.path.exists(self.dir):
@@ -524,8 +523,8 @@
                 #logging.info("xapianSearch: finds: %r" % hits)
                 def dict_decode(d):
                     """ decode dict values to unicode """
-                    for k, v in d.items():
-                        d[k] = d[k].decode(config.charset)
+                    for key in d:
+                        d[key] = d[key].decode(config.charset)
                     return d
                 pages = [dict_decode(hit['values']) for hit in hits]
                 logging.info("xapianSearch: finds pages: %r" % pages)
--- a/MoinMoin/security/autoadmin.py	Fri Feb 23 09:38:23 2007 +0100
+++ b/MoinMoin/security/autoadmin.py	Fri Feb 23 13:06:42 2007 +0100
@@ -84,7 +84,6 @@
 
     def save(self, editor, newtext, rev, **kw):
         request = self.request
-        has_member = request.dicts.has_member
         username = request.user.name
         pagename = editor.page_name
 
@@ -103,7 +102,7 @@
 
         parts = pagename.split('/')
         if len(parts) == 2:
-            mainpage, subpage = parts
+            subpage = parts[1]
             if subpage in grouppages and not self.admin(pagename):
                 return False
 
--- a/MoinMoin/server/STANDALONE.py	Fri Feb 23 09:38:23 2007 +0100
+++ b/MoinMoin/server/STANDALONE.py	Fri Feb 23 13:06:42 2007 +0100
@@ -178,7 +178,7 @@
     def serve_forever(self):
         """ Create a thread pool then invoke base class method """
         from threading import Thread
-        for i in range(self.poolSize):
+        for dummy in range(self.poolSize):
             t = Thread(target=self.serve_forever_thread)
             t.start()
         SimpleServer.serve_forever(self)
@@ -390,7 +390,7 @@
 
 
 try:
-    from tlslite.api import TLSSocketServerMixIn, X509, X509CertChain, SessionCache, parsePEMKey, TLSError
+    from tlslite.api import TLSSocketServerMixIn, X509, X509CertChain, SessionCache, parsePEMKey
     from tlslite.TLSConnection import TLSConnection
 except ImportError:
     pass
--- a/MoinMoin/util/__init__.py	Fri Feb 23 09:38:23 2007 +0100
+++ b/MoinMoin/util/__init__.py	Fri Feb 23 13:06:42 2007 +0100
@@ -9,6 +9,18 @@
 
 import os, sys, re, random
 
+# do the pickle magic once here, so we can just import from here:
+# cPickle can encode normal and Unicode strings
+# see http://docs.python.org/lib/node66.html
+try:
+    import cPickle as pickle
+except ImportError:
+    import pickle
+
+# Set pickle protocol, see http://docs.python.org/lib/node64.html
+PICKLE_PROTOCOL = pickle.HIGHEST_PROTOCOL
+
+
 #############################################################################
 ### XML helper functions
 #############################################################################
@@ -114,6 +126,6 @@
 
 
 def random_string(length):
-    chars = ''.join([chr(random.randint(0, 255)) for x in xrange(length)])
+    chars = ''.join([chr(random.randint(0, 255)) for dummy in xrange(length)])
     return chars
 
--- a/MoinMoin/widget/html.py	Fri Feb 23 09:38:23 2007 +0100
+++ b/MoinMoin/widget/html.py	Fri Feb 23 13:06:42 2007 +0100
@@ -7,7 +7,6 @@
 """
 
 from MoinMoin import wikiutil
-from MoinMoin.widget.base import Widget
 
 # sort attributes or not? (set to 1 by unit tests)
 _SORT_ATTRS = 0
@@ -666,6 +665,7 @@
 ### Widgets
 #############################################################################
 
+#from MoinMoin.widget.base import Widget
 #class FormWidget(Widget):
 #    """ Widget to display data as an HTML form.
 #
--- a/MoinMoin/wikisync.py	Fri Feb 23 09:38:23 2007 +0100
+++ b/MoinMoin/wikisync.py	Fri Feb 23 13:06:42 2007 +0100
@@ -10,14 +10,8 @@
 import socket
 import xmlrpclib
 
-try:
-    import cPickle as pickle
-except ImportError:
-    import pickle
-
-
 from MoinMoin import wikiutil
-from MoinMoin.util import lock
+from MoinMoin.util import lock, pickle
 from MoinMoin.Page import Page
 from MoinMoin.PageEditor import PageEditor
 from MoinMoin.packages import unpackLine, packLine
@@ -156,7 +150,7 @@
         """ Returns the InterWiki ID. """
         return NotImplemented
 
-    def get_pages(self, **kwargs):
+    def get_pages(self, **kw):
         """ Returns a list of SyncPage instances. """
         return NotImplemented
 
@@ -310,7 +304,7 @@
 
     def getGroupItems(self, group_list):
         """ Returns all page names that are listed on the page group_list. """
-        from MoinMoin.wikidict import Group
+        from MoinMoin.wikidicts import Group
         pages = []
         for group_pagename in group_list:
             pages.extend(Group(self.request, group_pagename).members())
--- a/MoinMoin/xmlrpc/__init__.py	Fri Feb 23 09:38:23 2007 +0100
+++ b/MoinMoin/xmlrpc/__init__.py	Fri Feb 23 13:06:42 2007 +0100
@@ -665,7 +665,7 @@
         else:
             newpage = Page(self.request, pagename, rev=to_rev)
             newcontents = lambda: newpage.get_raw_body_str()
-            newrev = newpage.get_real_rev()
+            newrev = newpage.get_real_rev() # XXX newrev unused
 
         if oldcontents() and oldpage.get_real_rev() == newpage.get_real_rev():
             return xmlrpclib.Fault("ALREADY_CURRENT", "There are no changes.")